Currently I use Fish as my main shell on local and remote hosts.
I connect to remote hosts via ssh and sftp. I wanted to open or reuse a remote tmux whenever I connect, automatically, by default; so I added this to my ~/.ssh/config
:
Host example.com
RemoteCommand tmux a; or tmux
RequestTTY yes
The problem is that now I cannot connect through sftp
, nor can I run a direct command from my local CLI:
➤ ssh example.com ping localhost
Cannot execute command-line and remote command.
➤ sftp example.com
Cannot execute command-line and remote command.
Connection closed
So, my question is: How can I define a default command to be executed when opening a new interactive SSH session, but make it overridable?