python 中使用 paramiko 模块,远程执行命令

 时间:2024-10-21 07:44:52

1、导入paramiko 模块#!/usr/bin/pythonimport paramiko

python 中使用 paramiko 模块,远程执行命令

3、创建命令执行函数def ssh_exec_cmd( _ssh_fd, _cmd ): return _ssh_fd.exec_command( _cmd )

python 中使用 paramiko 模块,远程执行命令

5、使用示例if __name__ == '__main__': sshd = s衡痕贤伎sh_connect( '192.168.134.220', 'root', '1' ) stdin, stdout, stderr = ssh_exec_cmd( sshd, 'ls' ) err_list = stderr.readlines() if len( err_list ) > 0: print 'ERROR:' + err_list[0] exit() for item in stdout.readlines(): print item, ssh_close( sshd )

python 中使用 paramiko 模块,远程执行命令
  • Python决定它是否是一个函数
  • Unable to create .git/index.lock File exists
  • 怎么在ubuntu上安装anaconda
  • 怎么使用JDBC连接SQL Server2008
  • Linux-文件搜索命令find的使用
  • 热门搜索
    枪神纪怎么安装 宁静致远是什么意思 腿上有红血丝怎么办 乌龟壳烂了怎么办 ipad如何截图 在校奖惩情况怎么写 大便不成形是什么原因造成的 ds是什么车 生活中的经济学 如何预防流感