首页 > 其他 > 详细

use paramiko to connect remote server and execute command

时间:2018-09-20 00:42:14      阅读:191      评论:0      收藏:0      [点我收藏+]
#!/usr/bin/env python

import sys, paramiko

hostname = ‘‘
password = ‘‘
command = ‘ls‘

username = ""
port = 22

try:
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.WarningPolicy)

    client.connect(hostname, port=port, username=username, password=password)

    stdin, stdout, stderr = client.exec_command(command)
    print(stdout.read(), end=‘‘)

finally:
    client.close()

use paramiko to connect remote server and execute command

原文:https://www.cnblogs.com/otfsenter/p/9678354.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!