0

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?

4
  • Doesn't the jump host functionality built into open ssh provide this, but much easier and securely? Commented Dec 26, 2022 at 23:49
  • @MarcusMüller I need to send the password through, so as far as I understood jump hosts they are no option for that. Commented Dec 27, 2022 at 0:01
  • You misunderstood that, then. In a ssh jump host, that is unproblematic. Commented Dec 27, 2022 at 9:05
  • @MarcusMüller I'm not sure what I should do with your post. If you know how I can squeeze a password into a jump host, feel free to tell me. Commented Dec 27, 2022 at 22:18

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.