python 编写远程连接服务器脚本

import paramiko

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('10.116.33.116', username='root', password='123456')
stdin, stdout, stderr = client.exec_command('ls -l')
stdin, stdout, stderr = client.exec_command('echo hehehaha')
stdin, stdout, stderr = client.exec_command('ifconfig')
print stdout.read()
client.close()

猜你喜欢

转载自www.cnblogs.com/yaok430/p/9019633.html