pip3 install -r requirements.txt
pip freeze # 生成
paramiko
基础使用
import paramikodef testSSH(): ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('192.168.188.200',22,'root','admin') # if use sshkey can ignor username and password stdin,stdout,stderr = ssh.exec_command('ifconfig') print(stdout.read().decode()) ssh.close()def testSFTP(): trs = paramiko.Transport(('192.168.188.200',22)) trs.connect(username='root',password='admin') sftp = paramiko.SFTPClient.from_transport(trs) sftp.put('./tests.py','/tmp/mustname.py') sftp.get('/tmp/fileremote','./fileremote') trs.close()testSFTP()