feat: save connector to a file
This commit is contained in:
parent
4bbc916282
commit
a493ab7e40
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.api-key
|
||||
.connector
|
||||
|
20
shell.sh
20
shell.sh
@ -3,15 +3,21 @@
|
||||
API_HOST="https://api.ssh.surf"
|
||||
API_KEY=$(cat .api-key)
|
||||
|
||||
[ -z $API_KEY ] && echo "API key not found" && exit 1
|
||||
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)
|
||||
hello=$(curl -w %{http_code} -sH "x-ssh-auth: $API_KEY" $API_HOST/hello -o /dev/null)
|
||||
|
||||
if [[ hello -ne 200 ]]; then
|
||||
echo "token not valid, exiting"
|
||||
exit 1
|
||||
if [[ hello -ne 200 ]]; then
|
||||
echo "token not valid, exiting"
|
||||
exit 1
|
||||
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=$(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//')
|
||||
|
||||
CONNECTOR=$(cat .connector)
|
||||
npx holesail $CONNECTOR
|
||||
|
Loading…
Reference in New Issue
Block a user