I have a PI at home that creates an SSH tunnel to my VPS with autossh so I can access it from my VPS.
When I log in to my PI from my VPS the connection keeps closing (which makes it unusable). For example when I edit a file or even when I cd to another directory, the connection closes.
However if I ssh from my PI to my VPS, the ssh session keeps running and doesn't close.
I would like to have a reliable session from my VPS to my PI
Here is the command I use to connect to create the tunnel:
autossh -M 5233 -N -R 2514:localhost:22 vps -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -i /home/xbian/.ssh/id_rsa
and here is my ssh config on my PI sshd config
-o ServerAliveInterval=60
(they stay up for days typically). Your docs/flavour/distro might be different however.-M
option of autossh to be unreliable and always use-M 0
and let SSH do the connection monitoring (withTCPKeepAlive yes
(or "no
" for interactive connections) andServerAliveInterval=30
).