feat: save connector to a file

This commit is contained in:
CyberL1 2024-07-27 22:03:50 +02:00
parent 4bbc916282
commit a493ab7e40
2 changed files with 14 additions and 7 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.api-key
.connector

View File

@ -3,6 +3,8 @@
API_HOST="https://api.ssh.surf"
API_KEY=$(cat .api-key)
if [ ! -f .connector ]; then
echo "SSH Connector not found, getting for the first time"
[ -z $API_KEY ] && echo "API key not found" && exit 1
hello=$(curl -w %{http_code} -sH "x-ssh-auth: $API_KEY" $API_HOST/hello -o /dev/null)
@ -14,4 +16,8 @@ fi
CONNECTOR=$(curl -sH "x-ssh-auth: $API_KEY" -X POST -H "content-type: application/json" $API_HOST/exec --data '{ "cmd": "con --list | grep ssh - Port: 22", "pwd": "/root" }' | grep -o 'Connector: [^"]*' | sed 's/Connector: //' | sed 's/\\n//')
echo $CONNECTOR > .connector
fi
CONNECTOR=$(cat .connector)
npx holesail $CONNECTOR