Is there any way to force ssh to change it's working dir in ~/.ssh/config or by using other configuration files?I have a lot of servers with different environments. Each environment is installed in a specific directory and it would be really helpful to be in this specific directory right after login.Unfortunately, sometimes several environments can be hosted on the same server.That's why I need to make it config based, as currently I have a separate entry in config for each env. Example:Host env1User mePort 2222# here directory should be /srv/project/env1HostName 172.16.16.2Host env2_testUser mePort 2222# here directory should be /srv/project/env2_testHostName 172.16.16.2Host env54User mePort 2225# here directory should be /srv/project/env54HostName 172.16.16.3I can do it with ssh -t env54 'cd /srv/project/env54 ; bash', but it's annoying to retype it each time or even put it in an alias.I believe the *nix way is to handle it via configuration.
force ssh to change dir after login based on config
ssh;ssh config
On the server, in .profile or whatever is run when you log in:if [ -n $USE_DIR_A ]; then    cd dir_aelif [ -n $USE_DIR_B ]; then    cd dir_bfiThen, on the local machine, set both variables:export USE_DIR_A=yesexport USE_DIR_B=yesand, set your .ssh/config like this:Host env1User mePort 2222# here directory should be /srv/project/env1SendEnv USE_DIR_AHostName 172.16.16.2Host env2_testUser mePort 2222# here directory should be /srv/project/env2_testSendEnv USE_DIR_BHostName 172.16.16.2Of course, you could just have one ssh config that sends one variable, and set that variable to the directory you want for each machine, but that's not what you asked for.Beware SSH connection sharing though: it can affect which scripts are run on start-up in subsequent connections.