Adding
ControlMaster auto
ControlPath ~/.ssh/sockets/%C
ControlPersist yes
to ~/.ssh/config automatically creates a control connection that stays alive for a long time. This works at home where Internet is stable but not when mobile, changing IPs etc. autossh, on the other hand, restarts ssh when it goes away. An ideal combination would be
- An ssh connection is initiated
- If there is no control socket, it starts autossh which starts another ssh to the same host establishing the control socket.
- It now uses as the socket as a slave.
Manually starting autossh to everywhere I might git push to is just not feasible.
I read Using autossh to create a persistent, multiplexed ssh connection without any port forwarding? and I understand ControlPersist will need to go, that's OK, the workflow above makes it absolutely unnecessary.