python学习:paramiko登录ssh
#!/usr/bin/env python #coding:utf-8 import paramiko ssh=paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) private_key=paramiko.RSAKey.from_private_key_file('id_rsa') ssh.connect(hostname='20.55.85.15',port=22,username='root',pkey=private_key) stdin,stdout,stderr=ssh.exec_command('df;ip addr') print(stdout.read().decode('utf-8')) ssh.close()