SSH 远程命令挂起
有谁知道为什么这个命令
ssh -v user@address "exec ssh-agent bash"
...会挂在这个输出上?
debug1: Sending command: exec ssh-agent bash
我正在尝试自动设置一组远程计算机,以便它们无需密码即可通过 SSH 相互连接。已对相关私钥文件进行 scp 处理。需要在每个实例上运行 ssh-add。但首先,我需要启动 ssh-agent。但上面的命令挂起。在每个实例上手动启动代理并不是一个真正的选择。
在远程计算机上手动运行“ps ux”可确认 ssh 代理正在运行:
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
感谢任何帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所看到的是预期的行为。 SSH 正在等待 bash 完成执行。如果您省略“bash”作为 ssh-agent 的参数,则 ssh-agent 会像您期望的那样进入后台。
因此,也许您打算运行:
查看 pstree 输出可以更清楚地显示正在发生的情况。
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:
looking at pstree output shows more clearly what is happening.