SSH – Remote Command in SSH Config File

sshssh-config

I'd like to set ssh_config so after just typing ssh my_hostname i end up in specific folder. Just like I would type cd /folder/another_one/much_much_deeper/.

How can i achieve that?

EDIT. It's have been marked as duplicate of "How to ssh into dir…" yet it is not my question.

I know i can execute any commands by tailing them to ssh command.
My question is about /ssh_config file not the command.

Best Answer

There wasn't a way to do that, until OpenSSH 7.6. From manual:

RemoteCommand

Specifies a command to execute on the remote machine after successfully connecting to the server. The command string extends to the end of the line, and is executed with the user's shell. Arguments to RemoteCommand accept the tokens described in the TOKENS section.

So now you can have

RemoteCommand cd /tmp && bash

It was introduced in this commit.

Related Question