大家好,我有三台服务器,我从 SSH 管理它,所以我制作了这个脚本来运行我的注册脚本“Register.py”,所以我每天都打开注册模式,所以问题是我如何在不关闭另一个的情况下登录到多个 SSH 连接
import paramiko
import os
ZI1={"ip":"192.168.1.2","pass":"Administrator"}
ZI2={"ip":"192.168.1.3","pass":"AdminTeachers"}
ZI3={"ip":"192.168.1.4","pass":"AdminStudents"}
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
for F1 in ZI1:
ssh.connect(ZI1["ip"],username='root', password=ZI1["pass"])
ssh.exec_command('./register.py -time 6') #6 hour so the script still working for 6 hours
ssh.close()
for F2 in ZI2:
ssh.connect(ZI2["ip"],username='root', password=ZI2["pass"])
ssh.exec_command('./register.py -time 6')
ssh.close()
for F3 in ZI3:
ssh.connect(ZI2["ip"],username='root', password=ZI2["pass"])
ssh.exec_command('./register.py -time 6')
ssh.close()
所以我必须做什么才能在不停止脚本的情况下打开 3 个会话!