我有 12 个裸机 CoreOS 集群节点(在 SuperMicro Blade 上)。每个节点都安装了相同的映像和云配置。(稳定版 717.3.0)
问题是我无法连接 sshd频繁地, 意思是有时我可以连接到 sshd。
所以我尝试了ssh -v
选项并发现了一些差异。我在失败的情况下注意到协议的远程响应是'dropbear_2013.60',而不是'OpenSSH_6.7'。
我发现的另一件奇怪的事情是,当我对节点进行端口扫描时,通常它会报告只有一个开放端口,22/tcp
对于 ssh 来说就像预期的那样,但如果一次又一次地这样做,有时它会报告如下内容:
# nmap XXX.XXX.XXX.112
Starting Nmap 5.21 ( http://nmap.org ) at 2015-07-24 23:48 KST
Nmap scan report for xxx.xxx.xxx (XXX.XXX.XXX.112)
Host is up (0.0026s latency).
Not shown: 996 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
5900/tcp open vnc
MAC Address: 00:25:XX:XX:XX:XX (Super Micro Computer)
经过快速搜索,我猜这些端口是用于 SuperMicro 的远程管理服务的。我尝试从 BIOS 配置中禁用它,但找不到合适的菜单。
我用浏览器打开它,但它并不总是能正常工作。有时我可以得到一些登录页面,有时它根本无法响应。这个 SuperMicro 东西会干扰 sshd 连接吗?还是其他原因?我在下面附上了 ssh 日志。
这是一个失败案例日志:
$ ssh -i ~/.ssh/se.pem -l core -v XXX.XXX.XXX.112
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/scari/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to XXX.XXX.XXX.112 [XXX.XXX.XXX.112] port 22.
debug1: Connection established.
debug1: identity file /Users/scari/.ssh/se.pem type -1
debug1: identity file /Users/scari/.ssh/se.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
ssh_exchange_identification: read: Connection reset by peer
这是另一个失败的案例:
$ ssh -i ~/.ssh/se.pem -l core -v XXX.XXX.XXX.112
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/scari/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to XXX.XXX.XXX.112 [XXX.XXX.XXX.112] port 22.
debug1: Connection established.
debug1: identity file /Users/scari/.ssh/se.pem type -1
debug1: identity file /Users/scari/.ssh/se.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version dropbear_2013.60
debug1: no match: dropbear_2013.60
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Server host key: RSA 95:0d:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:f4:3e
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
95:0d:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:f4:3e.
Please contact your system administrator.
Add correct host key in /Users/scari/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/scari/.ssh/known_hosts:15
RSA host key for XXX.XXX.XXX.112 has changed and you have requested strict checking.
Host key verification failed.
这是成功案例:
$ ssh -i ~/.ssh/se.pem -l core -v XXX.XXX.XXX.112
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/scari/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to XXX.XXX.XXX.112 [XXX.XXX.XXX.112] port 22.
debug1: Connection established.
debug1: identity file /Users/scari/.ssh/se.pem type -1
debug1: identity file /Users/scari/.ssh/se.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7
debug1: match: OpenSSH_6.7 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 56:07:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:fc:8d
debug1: Host 'XXX.XXX.XXX.112' is known and matches the RSA host key.
debug1: Found key in /Users/scari/.ssh/known_hosts:15
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/scari/.ssh/se.pem
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
Authenticated to XXX.XXX.XXX.112 ([XXX.XXX.XXX.112]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Requesting authentication agent forwarding.
debug1: Sending environment.
debug1: Sending env LC_ALL = ko_KR.UTF-8
debug1: Sending env LANG = ko_KR.UTF-8
Last login: Fri Jul 24 13:56:14 2015 from XXX.XXX.XXX.153
CoreOS stable (717.3.0)
我还检查了 sshd 是否正在运行。看起来它正在运行。
core112 ~ # systemctl list-units sshd*
UNIT LOAD ACTIVE SUB DESCRIPTION
sshd-keygen.service loaded active exited Generate sshd host keys
[email protected]:22-XXX.XXX.XXX.153:57197.service loaded active running OpenSSH per-connection server daemon (XXX.XXX.XXX.153:57197)
sshd.socket loaded active listening OpenSSH Server Socket
答案1
我今天在配置 coreos 的 ec2s 上遇到了这个问题
对我有用的是,首先检查ssh-add -l
ssh 代理中有哪些密钥。我有 2 个。我删除了它们ssh-add -D
然后注销,重新 ssh 登录,然后我就可以ssh -A -i ~/.ssh/aws_ec2.pem [email protected]
fleetctl ssh ...