Remote command in ssh config file

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.


I'd like to set ssh_config so after just typing ssh my_hostname

It is not possible. There is no option to achieve that in ssh_config. The closest to it is setting up a bash alias or bash function, such as

myssh() {
    ssh -t $1 "cd /dir/; bash"
}

Tags:

Ssh

Ssh Config