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

Posted on 2018-05-10 14:52  风行天下-2080  阅读(283)  评论(0编辑  收藏  举报

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()

Copyright © 2024 风行天下-2080
Powered by .NET 8.0 on Kubernetes