Im trying to SSH to host #1, who has access to host #2, and on host #2 I want to run a command. All from my local machine.
This bit works fine:
ssh host1 -t "command; ssh user@host2"
But, on host2, I also want to cd to a directory and then stay connected
I tried using this:
ssh host1 -t "command; ssh user@host2 -t 'command; cd /some/path/'"
The output I get is:
Connection to host2 closed.
Connection to host1 closed.
And ends up on my local machine
The expected result was my session being on host2 in the /some/path/ directory thru host1