I have ten or so servers that I connect to with SSH on a regular basis. Each has an entry in my local computer's ~/.ssh/config file.
To avoid losing control of my running process when my Internet connection inevitably drops, I always work inside a tmux session. I would like a way to have tmux automatically connect every time an SSH connection is started, so I don't have to always type tmux attach || tmux new after I SSH in.
Unfortunately this isn't turning out to be as simple as I originally hoped.
- I don't want to add any commands to the
~/.bashrcon the servers because I only want it for SSH sessions, not local sessions. - Adding
tmux attach || tmux newto the~/.ssh/rcon the servers simply results in the errornot a terminalbeing thrown after connection, even when theRequestTTY forceoption is added to the line for that server in my local SSH config file.
~/.ssh/config. The answer most people will probably need, is therefore stackoverflow.com/a/52838493/5354137. - Sixtyfive