I have a situation that isn't ideal as far as security and work is concerned, but the idea is that I have to connect to a server via another, I can't store keys anywhere and I have to do varying stuff in the inner shell. So after some tinkering I got this to work:
sshpass -p"mypass1" ssh mxd 'sshpass -p"mypass2" ssh -t 10.10.10.10 "cd /path/to/work; /bin/bash -i"' So the cd is done and I can type and execute commands in the inner shell.
As this isn't really readable I tried to improve it with heredoc:
sshpass -p"mypass1" ssh mxd bash <<EOF1 sshpass -p"mypass2" ssh -t 10.10.10.10 bash <<EOF2 cd /path/to/work /bin/bash -i EOF2 EOF1 The thing is that it performs the cd (the prompt says so), but then immediately exits both ssh. The goal is that equally to the first snippet I can enter commands in the inner shell. What am I missing here?