==SSHClient 封装Transport==
import paramiko, socks
sock = socks.socksocket()
host, port = '103.67.206.10', 11113
sock.set_proxy(proxy_type=socks.SOCKS5,addr=host,port=port,username='lx',password='Qaz123')
sock.connect(('10.200.124.37', 33899))
private_key = paramiko.RSAKey.from_private_key_file('/root/.ssh/starsliao-gmt')
transport = paramiko.Transport(sock)
transport.connect(username='www', pkey=private_key)
ssh = paramiko.SSHClient()
ssh._transport = transport
stdin, stdout, stderr = ssh.exec_command('df')
print(stdout.read())
transport.close()
sock.close()
==基于公钥秘钥连接==
import paramiko, socks
sock = socks.socksocket()
host, port = '103.67.206.10', 11113
sock.set_proxy(proxy_type=socks.SOCKS5,addr=host,port=port,username='lx',password='Qaz123')
sock.connect(('10.200.124.37', 33899))
private_key = paramiko.RSAKey.from_private_key_file('/root/.ssh/starsliao-gmt')
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname='10.200.124.37', port=33899, username='www', pkey=private_key, sock=sock)
stdin, stdout, stderr = ssh.exec_command('df')
print(stdout.read())
ssh.close()
sock.close()
如果您喜欢本站,点击这儿可以捐赠本站
这些信息可能会帮助到你: 联系作者 | 报毒说明
修改版本软件,加群提示等均为修改者自留,非本站信息,注意鉴别
这些信息可能会帮助到你: 联系作者 | 报毒说明
修改版本软件,加群提示等均为修改者自留,非本站信息,注意鉴别
评论(0)