Created
November 25, 2020 12:39
-
-
Save my-given-name-is-jeremy/41435eef6235b34f57b7df1836e3c503 to your computer and use it in GitHub Desktop.
Firewalla ssh tunnel api POC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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