.ssh/config to start remote session in zsh
I don't think that is possible with ~/.ssh/config
. The -t
can be covered by adding a RequestTTY yes
, but it doesn't seem you can specify the remote command in ~/.ssh/config
.
However, with zsh
, you could add a:
alias -g 'serveralias=serveralias -t zsh'
to your ~/.zshrc
.
Or make a function like:
zssh() ssh "$@" -t zsh
For anyone arriving here years later, since 2017 it's possible to put everything in the config file:
Host host_1
HostName 1.2.3.4
User root
Port 22
RequestTTY yes
RemoteCommand zsh
I concur with @Stephane that there isn't a way to do this using the ~/.ssh/config file
. Another approach would be to use the ~/.ssh/authorized_keys
file on the remote server. If you add a line like this:
command="exec zsh" ssh-dss ..... rest of key ....
Then you can just ssh as normal and you'll get a zsh on the remote server.
Example
On server, ssh to remote.
$ ssh saml@greeneggs
On remote server, confirming we're in a zsh
.
[saml@greeneggs]~% ps -eaf|grep $$
saml 1974 1973 1 10:34 pts/3 00:00:00 zsh
saml 2023 1974 0 10:34 pts/3 00:00:00 ps -eaf
saml 2024 1974 0 10:34 pts/3 00:00:00 grep --color=auto 1974
You can do more elaborate things using this file, see this Q&A, titled: ssh, start a specific shell, and run a command on the remote machine?.