def main(): options,server,remote = parse_options() password = None if options.readpass: password = getpass.getpass('Enter SSH password:') client = paramiko.SSHClient() client.load_system_host_keys() client.set_missing_host_key_policy(paramiko.WarningPolicy()) verbose('Connection to ssh host %s:%d...' % (server[0],server[1])) try: client.connect(server[0],server[1],username=options.user,key_filename=options,keyfile,look_for_keys=options.look_for_keys,password=password) except Exception as e: print('*** Failed to connect to %s:%d:%r' % (server[0],server[1],sys.exit(1))) verbose('Now forwarding remote port %d to %s:%d...' % (options.port,remote[0],remote[1])) try: reverse_forward_tunnel(options.port,remote[0],remote[1],client.get_transport) except KeyboardInterrupt: print('C-c: Port forwarding stopped.') sys.exit(0)
python
原创
©著作权归作者所有:来自51CTO博客作者lijingsan1的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
PythonPython
-
Python之FastAPI构建Python Web
FastAPI 构建高效的 Python Web
ico Python 服务器