开发者

Check whether a connection exists to a remote host using paramiko

开发者 https://www.devze.com 2022-12-12 17:16 出处:网络
I\'m using single object of paramiko.SSHClient() for executing a command on a remote machine. When I use ssh.exec_command(cmd), and the connection to remote host is lost, ssh.exec_command hangs up.

I'm using single object of paramiko.SSHClient() for executing a command on a remote machine. When I use ssh.exec_command(cmd), and the connection to remote host is lost, ssh.exec_command hangs up.

Is there a way to check for connection 开发者_C百科existence before ssh.exec_command()?


If you have a long running SSH connection, you may want to use the Keep Alive parameter via Transport.set_keepalive.


As an alternate possibility, maybe execnet would work. It wraps the command line ssh command instead, so it's definitely not the paramiko approach... just a though.

0

精彩评论

暂无评论...
验证码 换一张
取 消