feat: remove api key after getting the connector

This commit is contained in:
CyberL1 2024-08-02 10:43:19 +02:00
parent 61ba3516d9
commit e74b73a640

View File

@ -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)