I have a handy alias as follows:

sshpass -p "the_password" ssh -o StrictHostKeyChecking=no root@

That will give me a quick way to login to a remote device, and get a command prompt which has tab completion.

But the first thing I then ALWAYS do, is cd to a different directory. Consequently I want to add that as a command to the end of the line, like this:

sshpass -p "the_password" ssh -o StrictHostKeyChecking=no root@ 'cd /tmp/Data/fx'

But if I do that then I don't get a prompt at all! It just sits there doing nothing. Next, I tried to make it give me a command prompt, by using this:

sshpass -p "the_password" ssh -o StrictHostKeyChecking=no root@ 'cd /tmp/Data/fx; /bin/bash -i'

That nearly works.

I have changed to the right directory, and I have a command prompt. But, I don't have any tab-completion, and the up-arrow doesn't show me the most recent commands.

What am I missing?

  • 3
    Did you try with -t to force a pty allocation? ssh with a command is not really meant for interactive use though... – Celada Apr 23 '15 at 14:29
  • Cool, yes, the -t option works. – Nick Apr 23 '15 at 15:33

When you run /bin/bash -i you are launching another instance of the shell. Therefore it's normal that you don't have access to your previous history.

  • OK, but that doesn't explain why the tab-completion doesn't work. – Nick Apr 23 '15 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.