如何解决如何使用python创建多个具有相同ip地址的ssh会话
下面的代码创建一个ssh会话,运行该命令并打印结果。
import paramiko
user_name="xxx"
pass_word="xxxx"
ip="xx.xx.xxx.xx"
print ("please wait creating ssh connection..,")
ssh_client=paramiko.SSHCLIENT()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print ("please wait connecting to remote server..,")
ssh_client.connect(hostname="ip",username="user_name",password="pass_word");
cmd="ls /home/"
print ("please wait,executing command on remote server..,")
stdin,stdout,stderr=ssh_client.exec_command(cmd)
print ("successfully executed command on remote server..,")
stdout=stdout.readlines()
但是,如何同时在同一主机上创建两个会话并运行不同的命令。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。