def _paramiko_tunnel(lport, rport, server, remoteip, keyfile=None, password=None):
 (username, server, port) = _split_server(server)
 client = paramiko.SSHClient()
 client.load_system_host_keys()
 client.set_missing_host_key_policy(paramiko.WarningPolicy())
 try:
  client.connect(server, port, username=username, key_filename=keyfile, look_for_keys=True, password=password)
 except Exception as e:
  print(('*** Failed to connect to %s:%d: %r' % (server, port, e)))
  sys.exit(1)
 signal.signal(signal.SIGINT, signal.SIG_IGN)
 try:
  forward_tunnel(lport, remoteip, rport, client.get_transport())
 except KeyboardInterrupt:
  print('SIGINT: Port forwarding stopped cleanly')
  sys.exit(0)
 except Exception as e:
  print(('Port forwarding stopped uncleanly: %s' % e))
  sys.exit(255)

def _paramiko_tunnel ( lport , rport , server , remoteip , keyfile = None , password = None ) : ( username , server , port ) = _split_server ( server ) client = paramiko . SSHClient ( ) client . load_system_host_keys ( ) client . set_missing_host_key_policy ( paramiko . WarningPolicy ( ) ) try : client . connect ( server , port , username = username , key_filename = keyfile , look_for_keys = True , password = password ) except Exception as e : print ( ( '*** Failed to connect to %s:%d: %r' % ( server , port , e ) ) ) sys . exit ( 1 ) signal . signal ( signal . SIGINT , signal . SIG_IGN ) try : forward_tunnel ( lport , remoteip , rport , client . get_transport ( ) ) except KeyboardInterrupt : print ( 'SIGINT: Port forwarding stopped cleanly' ) sys . exit ( 0 ) except Exception as e : print ( ( 'Port forwarding stopped uncleanly: %s' % e ) ) sys . exit ( 255 )
function for actually starting a paramiko tunnel .