SSH连接问题仅由bash脚本引起

时间:2018-04-05 10:54:42

标签: linux bash ssh

bash脚本尝试通过以下方式连接远程主机:

CNX=$(bash -c 'exec 3<> /dev/tcp/'$OPCION'/'22';echo $?' 2>/dev/null)
   if [ "$CNX" = "1" ]; then
     telnet "$OPCION"
   else
      ssh -vvv "$OPCION"
fi

但它完成了这个错误:

ssh_exchange_identification: read: Connection reset by peer

[myuser@vmlnx01 .escrip]$ ./menu

Usar CRTL + C para salir.
Patron a buscar:
remot
1) RemoteRouter
#? 1
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 57: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to RemoteRouter [1.1.1.1] port 22.
debug1: Connection established.
debug1: identity file /home/myuser/.ssh/id_rsa type -1
debug1: identity file /home/myuser/.ssh/id_rsa-cert type -1
debug1: identity file /home/myuser/.ssh/id_dsa type -1
debug1: identity file /home/myuser/.ssh/id_dsa-cert type -1
debug1: identity file /home/myuser/.ssh/id_ecdsa type -1
debug1: identity file /home/myuser/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/myuser/.ssh/id_ed25519 type -1
debug1: identity file /home/myuser/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
ssh_exchange_identification: read: Connection reset by peer

连接到没有脚本的远程主机成功:

^C[myuser@vmlnx01 .escrip]$ ssh RemoteRouter
------------------
ACCESO RESTRINGIDO
------------------
myuser@RemoteRouter's password:

远程主机是路由器,它显示此日志:

RP/0/RSP1/CPU0:Apr  5 03:55:46.210 : SSHD_[65590]: %SECURITY-SSHD-6-INFO_GENERAL : Client 10.108.120.4 closes socket connection
RP/0/RSP1/CPU0:Apr  5 03:55:46.211 : SSHD_[65590]: %SECURITY-SSHD-3-ERR_GENERAL : Failed in version exchange

0 个答案:

没有答案