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
To make it permanent, use RemoteCommand
in your ~/.ssh/config
file, e.g.
Host myhost
HostName IP
User ubuntu
IdentityFile ~/.ssh/id_rsa
RemoteCommand cd /path/to/directory; $SHELL -il
Related:
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.
You could do something like the one I'm using. Make an alias as the one below.
alias ssh 'ssh -t \!* "cd $PWD; csh"'
(here, csh could also be replaced by bash)
This brings you directly to the 'current' path on the other machine. The usage would be like [$] ssh some machine However, I find that it works slow. So, I'm looking for an alternative.