ssh-tunnel

Python: Automatically reconnect ssh tunnel after remote server gone down

匆匆过客 提交于 2021-02-19 05:32:30
问题 I have implemented a function to establish an ssh-tunnel in Python, so I can insert data in a DB behind a NAT (no port forwarding available). import paramiko from sshtunnel import SSHTunnelForwarder def fnc_ssh_tunnel(): try: sshServer = SSHTunnelForwarder( (SSH_IP, SSH_PORT), ssh_username = SSH_USER, ssh_password = SSH_PASS, set_keepalive = float(SSH_KEEP_ALIVE), remote_bind_address = (DB_IP, DB_PORT), ) sshServer.start() localPort = sshServer.local_bind_port logPrint("SSH Tunnel Started to

Setup SSH tunnel with Paramiko to access PostgreSQL

笑着哭i 提交于 2021-02-08 09:14:12
问题 I currently use Paramiko to access an SFTP server and connect to the PostgreSQL on the same server. I found many examples using sshtunnel to log on PostgreSQL. But I don't know how to do it with pure Paramiko. Currently my code looks something like: # establish SSH tunnel self.ssh = paramiko.SSHClient() self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.ssh.connect(hostname=host, username=user, password=password) # setup SFTP server self.sftp = self.ssh.open_sftp() # connect

How to send HTTP GET request from remote host using SSH connection in Python?

妖精的绣舞 提交于 2021-02-04 21:29:38
问题 I'm using an SSH connection with Paramiko. My code: client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(hostname=remote_host, username=remote_user, password=remote_password, port=remote_port) How to send HTTP GET request from connected remote host (use it like a proxy)? I've found solution according to the answer: with SSHTunnelForwarder( ssh_address_or_host=(remote_host, remote_port), ssh_username=remote_user, ssh_password=remote_password

SSHTunnel not installed correctly?

有些话、适合烂在心里 提交于 2021-01-28 23:51:09
问题 I'm using anaconda python 3.5.2 in PyCharm using windows 10. I'm pretty new to python and a complete noob to PyCharm! I just want to use SSHtunnel. I have intalled the package and it shown in the project interpreter page: However when I try to run the code which I cut and pasted from example 1 here https://github.com/pahaz/sshtunnel: from sshtunnel import SSHTunnelForwarder server = SSHTunnelForwarder( 'pahaz.urfuclub.ru', ssh_username="pahaz", ssh_password="secret", remote_bind_address=('127

SSHTunnel not installed correctly?

↘锁芯ラ 提交于 2021-01-28 23:50:15
问题 I'm using anaconda python 3.5.2 in PyCharm using windows 10. I'm pretty new to python and a complete noob to PyCharm! I just want to use SSHtunnel. I have intalled the package and it shown in the project interpreter page: However when I try to run the code which I cut and pasted from example 1 here https://github.com/pahaz/sshtunnel: from sshtunnel import SSHTunnelForwarder server = SSHTunnelForwarder( 'pahaz.urfuclub.ru', ssh_username="pahaz", ssh_password="secret", remote_bind_address=('127

SSHTunnel not installed correctly?

♀尐吖头ヾ 提交于 2021-01-28 23:32:47
问题 I'm using anaconda python 3.5.2 in PyCharm using windows 10. I'm pretty new to python and a complete noob to PyCharm! I just want to use SSHtunnel. I have intalled the package and it shown in the project interpreter page: However when I try to run the code which I cut and pasted from example 1 here https://github.com/pahaz/sshtunnel: from sshtunnel import SSHTunnelForwarder server = SSHTunnelForwarder( 'pahaz.urfuclub.ru', ssh_username="pahaz", ssh_password="secret", remote_bind_address=('127

Translate Oracle SQL Developer SSH Host w/ Local Port Forward Connection to Python

岁酱吖の 提交于 2020-12-30 04:45:49
问题 I'm trying to create a Python connection to a remote server through an SSH Jump Host (one I've successfully created in Oracle SQL Developer) but can't replicate in Python. Can connect to SSH Host successfully but fail to forward the port to the remote server due to timeout or error opening tunnels. Safe to assume my code is incorrect rather than server issues. Also need a solution that doesn't use the "with SSHTunnelForwarder() as server:" approach because I need a continuous session similar

Translate Oracle SQL Developer SSH Host w/ Local Port Forward Connection to Python

假如想象 提交于 2020-12-30 04:44:51
问题 I'm trying to create a Python connection to a remote server through an SSH Jump Host (one I've successfully created in Oracle SQL Developer) but can't replicate in Python. Can connect to SSH Host successfully but fail to forward the port to the remote server due to timeout or error opening tunnels. Safe to assume my code is incorrect rather than server issues. Also need a solution that doesn't use the "with SSHTunnelForwarder() as server:" approach because I need a continuous session similar