import paramiko ssh = paramiko.SSHClient() print ssh.get_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(hostname="10.239.xx.xx",port=22,username="root",password="xxxx") stdin,stdout,stderr = ssh.exec_command("python test.py") res = stdout.read() err = stderr.read() result = res if res else err print result ssh.close()
以上