Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Firewalla ssh tunnel api POC
import requests, json
from sshtunnel import open_tunnel
REMOTE_SERVER_IP = "<address>"
REMOTE_SERVER_USER = "pi"
REMOTE_SERVER_PUBKEY = "/path/to/pubkey"
REMOTE_BIND_PORT = 8834
LOCAL_BIND_PORT = 10022
with open_tunnel(
(REMOTE_SERVER_IP, 22),
ssh_username=REMOTE_SERVER_USER,
ssh_pkey=REMOTE_SERVER_PUBKEY,
remote_bind_address=('127.0.0.1', REMOTE_BIND_PORT),
local_bind_address=('0.0.0.0', LOCAL_BIND_PORT)
) as server:
response = requests.get(f"http://127.0.0.1:{server.local_bind_port}/v1/host/all")
if response.status_code == 200:
print(json.dumps(response.json(),indent=2))
elif response.status_code == 404:
print('Not Found.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment