开发者

Check whether a connection exists to a remote host using paramiko

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜