diff --git a/connect.sh b/connect.sh index ffaa21a..95231cf 100644 --- a/connect.sh +++ b/connect.sh @@ -1,9 +1,9 @@ #!/bin/bash -API_HOST="https://api.ssh.surf" -API_KEY=$(cat .api-key) - if [ ! -f .connector ]; then + API_HOST="https://api.ssh.surf" + API_KEY=$(cat .api-key) + echo "SSH Connector not found, getting for the first time" [ -z $API_KEY ] && echo "API key not found" && exit 1 @@ -17,6 +17,9 @@ if [ ! -f .connector ]; then 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 + + echo "Connector saved, deleting .api-key" + rm .api-key fi CONNECTOR=$(cat .connector)