I got an SSH tunnel done with Pexpect
module which I'm only allowed to read from. How can I check if the connection is still up and running e.g. if there was any network connection issue in the meantime? The other side of my tunnel sends messages randomly so there may be like one day without any data in the stream. I've checked pexpect.isalive()
function but it seems like it doesn't detect that the network connection is down.
How can I monitor health of SSH tunnel with Pexpect?
833 views Asked by kozooh At
1
I think you can use
ssh
'sServerAliveInterval
andServerAliveCountMax
options:If your
ssh
server does not support these options you can still tryTCPKeepAlive
:And then in your
pexpect
script you only need to checkpexpect.EOF
.The following is from
ssh_config
man page: