Python: Automatically reconnect ssh tunnel after remote server gone down
问题 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