python远程执行命令
def run():
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(HostIP, 22, username, passwd)
stdin, stdout, stderr = ssh.exec_command('w')
cmd_result = stdout.read(), stderr.read()
for line in cmd_result:
print line
except Exception as ex:
print "\tError %s\n" % ex
Welcome to visit