【问题标题】:SSH Remote Command HangsSSH 远程命令挂起
【发布时间】:2011-05-27 10:55:27
【问题描述】:

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

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

感谢任何帮助。

【问题讨论】:

    标签: ssh ssh-agent


    【解决方案1】:

    您看到的是预期的行为。 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
    

    【讨论】:

    • 不是在会话中运行ssh-agent,然后终止无用吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-16
    • 1970-01-01
    • 2018-04-21
    相关资源
    最近更新 更多