135498
135498

Reputation: 271

SSH Remote Command Hangs

Does anyone know why this command,

ssh -v user@address "exec ssh-agent bash"

...would hang on this output?

debug1: Sending command: exec ssh-agent bash

I'm trying to automatically setup a set of remote machines so they can SSH into each other without passwords. Have already scp'd over the relevant private key file. Need to run ssh-add on each instance. But first, I need to start the ssh-agent. But the command above hangs. Starting the agent manually on each instance is not really an option.


Running "ps ux" on the remote machine manually confirms that the ssh-agent is running:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
ubuntu     746  0.0  0.2   8844  1380 ?        S    02:45   0:00 sshd: ubuntu@notty
ubuntu     747  0.0  0.1   4532  1096 ?        Ss   02:45   0:00 bash
ubuntu     748  0.0  0.0   3360   204 ?        Ss   02:45   0:00 ssh-agent bash
ubuntu     779  0.0  0.2   8844  1376 ?        S    02:51   0:00 sshd: ubuntu@pts/0
ubuntu     781  5.3  0.8   8260  5244 pts/0    Ss   02:51   0:00 -bash
ubuntu     813  0.0  0.1   4284  1076 pts/0    R+   02:52   0:00 ps ux

Any help is appreciated.

Upvotes: 0

Views: 4351

Answers (1)

md0
md0

Reputation: 37

What you see is the expected behavior. SSH is waiting for bash to finish execution. If you omit the "bash" as the argument to ssh-agent, then ssh-agent goes in the background like you expect it to.

So, perhaps you meant to run:

ssh -v user@address "ssh-agent"

looking at pstree output shows more clearly what is happening.

 |-+= 09556 root /usr/libexec/launchproxy /usr/sbin/sshd -i
 | \-+= 09557 root /usr/sbin/sshd -i
 |   \-+- 09560 root /usr/sbin/sshd -i
 |     \-+= 09561 root bash
 |       \--= 09562 root ssh-agent bash

Upvotes: 2

Related Questions