此问题与Taking the input from auto-execute user login using ssh execute command有关,我尝试采用另一种方法解决当前问题。从远程卡住的paramiko ssh注销
由于paramiko循环永远在等待用户输入命令。我无法杀死,有任何进展或做任何事情。
stdin, stdout, stderr = self.connection.exec_command(command)
while not stdout.channel.exit_status_ready():
if stdout.channel.recv_ready():
alldata = stdout.channel.recv(1024)
rl, wl, xl = select.select([stdout.channel], [], [], 0.0)
if len(rl) > 0:
self.logger.info(stdout.channel.recv(1024),)
哪种方式,我尝试登录到使用的paramiko其他用户(root),并杀死这个remoteuser表。
在根:
$ skill -KILL -u remoteuser
我尝试使用线程,但由于它无法处理。它未能执行下一个线程。
thread1 = threading.Thread(target=remoteuser_stuckfreeze)
thread2 = threading.Thread(target=roottokillremoteuser)
thread1.start()
thread2.start()
thread1.join()
thread2.join()
谢谢。