この問題は、現在の問題を解決するために別のアプローチを試みる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()
ありがとうございます。