【发布时间】:2016-07-03 20:14:51
【问题描述】:
我正在尝试从一台机器/ip 多次执行以下代码
#!/bin/bash
for i in `seq 1 10`;
do
ssh 11.156.112.111 pwd
done
# I know that the script is useless, it's just for demonstration.
我不能同时在两个以上的终端中执行脚本,当我尝试在第三个终端中运行脚本时,它会冻结并且我无法登录,但我可以从另一台机器/ip 登录。
我的配置
# .ssh/config
Host *
ServerAliveInterval 10
ServerAliveCountMax 10
# sshd_config
UsePAM no
MaxSessions 100
MaxStartups 100
这是详细模式的输出,它在最后一行冻结:
OpenSSH_7.2p2, OpenSSL 1.0.2f 28 Jan 2016
debug1: Reading configuration data /home/neelix/.ssh/config
debug1: /home/neelix/.ssh/config line 1: Applying options for *
debug1: /home/neelix/.ssh/config line 11: Applying options for 11.156.112.111
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "11.156.112.111" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 11.156.112.111 [11.156.112.111] port 22.
debug1: Connection established.
debug1: identity file /home/neelix/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/neelix/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2
【问题讨论】:
-
尝试运行
ssh -v 11.156.112.111 pwd来捕捉 ssh 卡住的地方 -
我已经更新了问题。
-
您在问题中提到的脚本是卡住的确切脚本吗?
-
你可以再次运行它,然后再次运行edit,使用
-vvv运行以增加日志记录的详细程度吗? -
是的,完全一样,我使用
pwd或ls或其他什么都没关系,它在前3 或4 次迭代后卡住,然后在一段时间后ssh_exchange_identification: read: Connection reset by peer更多迭代...循环需要 20 分钟才能完成。