dlinux-connect/shell.sh
2024-07-27 21:49:09 +02:00

18 lines
557 B
Bash

#!/bin/bash
API_HOST="https://api.ssh.surf"
API_KEY=$(cat .api-key)
[ -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)
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//')
npx holesail $CONNECTOR