SSH远程命令挂起

时间:2010-12-18 02:50:09

标签: ssh ssh-agent

有谁知道为什么这个命令,

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

...会挂起这个输出吗?

debug1: Sending command: exec ssh-agent bash

我正在尝试自动设置一组远程计算机,以便他们可以在没有密码的情况下相互SSH。已经scp'd相关的私钥文件。需要在每个实例上运行ssh-add。但首先,我需要启动ssh-agent。但上面的命令挂了。在每个实例上手动启动代理并不是一个真正的选择。


在远程计算机上运行“ps ux”,手动确认ssh-agent正在运行:

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

感谢任何帮助。

1 个答案:

答案 0 :(得分:2)

您看到的是预期的行为。 SSH正在等待bash完成执行。如果省略“bash”作为ssh-agent的参数,则ssh-agent会像你期望的那样进入后台。

所以,也许你打算跑:

ssh -v user@address "ssh-agent"

查看pstree输出可以更清楚地显示正在发生的事情。

 |-+= 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
相关问题