SSH config file paragraph to open a specific directory on remote server

alias, config, ssh

Solution

In this post on ServerFault, they say you can't do it all through the ssh config file. But you can do it with the ssh config and your .bash_profile or whatever the terminal nerds call it. in the ssh config file add

Host dev
  Hostname server.com
  User joe

then in your .bash_profile add an alias

alias domain1="ssh dev -t 'cd domains/domain1; bash'"

Here the `dev` refers to what you set up in the config file.

In the Terminal, just type `domain1`, you will be asked to put in your password and will go straight to the directory. Make a new alias for all your domains and it will make logging in to each one super easy.

Problem

Is there a way to specifically ssh into a particular directory in remote location, specifically using the local ssh config file (not terminal)? Something like `Dir` option in the paragraph below, for example, ``` Host remote_dir Hostname remote_server User username Dir path/to/remote_dir/ ``` So, if I, ssh using the Host value from above paragraph, ``` ssh remote_dir ``` Then, I would like to be logged in and the terminal to be ready for me at `path/to/remote_dir/` of the remote server, ``` username@remote_server: path/to/remote_dir/ > pwd /home/username/path/to/remote_dir/ ```

Original source

Related problems