How to make SSH go directly to specific directory?

directory, ssh

Solution

This should work for you

ssh  -t second_machine "cd /very/long/path/to/directory/; bash"

Assumes you're wanting to run bash, substitute for a different shell if required.

Problem

when you do an "ssh second_machine" you are able to connect to second_machine on your home directory But usually i am working in my_machine in directory with very long path, and i want to connect to second_machine and move to my working directory right away. So everytime i have to: ssh second_machine cd /very/long/path/to/directory/ Is there a way to make it automatic ?? ( ssh automatically go to the desired directory )

Original source

Related problems