标签:toad 创建 exec 传输 class desktop param min 远程
import paramiko hostname = ‘192.168.88.31‘ port = 22 username = ‘root‘ password = ‘123‘ ssh = paramiko.SSHClient() #创建ssh对象 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) #允许连接不在know_hosts文件中的主机 ssh.connect(hostname=hostname,port=port,username=username,password=password) #连接服务器 stdin, stdout, stderr = ssh.exec_command("ls -ltr")#执行命令 print(stdout.read().decode(‘utf-8‘))
import paramiko hostname = ‘192.168.88.31‘ port = 22 username = ‘root‘ password = ‘123‘ t=paramiko.Transport((hostname,port)) t.connect(username=username,password=password) sftp = paramiko.SFTPClient.from_transport(t) sftp.put(r‘C:\Users\OYY\Desktop\a.txt‘, ‘/root/aaa.xmind‘) #上传 sftp.close()
import paramiko hostname = ‘192.168.88.31‘ port = 22 username = ‘root‘ password = ‘123‘ t=paramiko.Transport((hostname,port)) t.connect(username=username,password=password) sftp = paramiko.SFTPClient.from_transport(t) # 根据SSH传输协议的sftp会话,实现远程文件上传、下载等操作。 sftp.get(‘/root/jk.sh‘, r‘C:\Users\OYY\Desktop\jk.sh‘) #下载 sftp.close()
标签:toad 创建 exec 传输 class desktop param min 远程
原文地址:https://www.cnblogs.com/heiguu/p/10088316.html