-1

I have a handy alias as follows:

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

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@192.168.0.123 '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@192.168.0.123 '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?

Nick
  • 191
  • 2
  • 13
  • I suspect that /etc/inputrc file is not being sourced through my ssh method. – Nick Apr 23 '15 at 10:33
  • Just seen a comment that 'bind -f /etc/inputrc' should do the trick. But that doesn't appear to do anything. – Nick Apr 23 '15 at 10:55
  • Hi Nick, Welcome to the Stack Exchange network. This question is more a general computing question than it is programming-related. I reckon you’d have a better chance of getting good answers at [Super User](http://superuser.com/) or [Unix and Linux](http://unix.stackexchange.com/). – Anthony Geoghegan Apr 23 '15 at 13:23

1 Answers1

0
ssh -o [...] 'cd /tmp/Data/fx; /bin/bash -i'

When you ask ssh to run a command on the remote system, ssh doesn't normally allocate a PTY (pseudo-TTY) for the remote session. Not having a TTY alters the way that bash initializes itself, so its line-editing features aren't enabled. You can run ssh with -t to request a tty for the session:

ssh -t -o [...] 'cd /tmp/Data/fx; /bin/bash -i'

If you don't want to type that all the time, you could add this line to the ".ssh/config" file on your local host:

RequestTTY yes
Kenster
  • 23,465
  • 21
  • 80
  • 106