我正在尝试使用 ansible ad-hoc 测试与几个网络设备的连接,Ansible 安装在 Ubuntu 20.04.2 LTS 上。
问题:SSH 不工作,因为设备的密钥交换方法只有 ssh-RSA,服务器不支持。试图强制执行 ssh-RSA 但我知道它不可用,因为它没有作为密码协商的密钥交换方法之一发送。
Ansible_输出:
(venv) omera@sandbox:~/code/ansible/play_06$ ansible all -m ping
edge_02 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Unable to negotiate with 192.168.1.201 port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1",
"unreachable": true
}
edge_01 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Unable to negotiate with 192.168.1.200 port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1",
"unreachable": true
}
core_01 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Unable to negotiate with 192.168.1.202 port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1",
"unreachable": true
edge_02_debug_output:
Edge_02#
*Jun 7 07:49:14.738: SSH0: starting SSH control process
*Jun 7 07:49:14.738: SSH0: sent protocol version id SSH-1.99-Cisco-1.25
*Jun 7 07:49:14.741: SSH0: protocol version id is - SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.2
*Jun 7 07:49:14.741: SSH2 0: Server certificate trustpoint not found. Skipping hostkey algo = x509v3-ssh-rsa
*Jun 7 07:49:14.741: SSH2 0: kexinit sent: hostkey algo = ssh-rsa
*Jun 7 07:49:14.741: SSH2 0: kexinit sent: encryption algo = aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
*Jun 7 07:49:14.741: SSH2 0: kexinit sent: mac algo = hmac-sha1,hmac-sha1-96
*Jun 7 07:49:14.741: SSH2 0: SSH2_MSG_KEXINIT sent
*Jun 7 07:49:14.741: SSH2 0: SSH2_MSG_KEXINIT received
*Jun 7 07:49:14.741: SSH2 0: kex: client->server enc:aes128-ctr mac:hmac-sha1
*Jun 7 07:49:14.741: SSH2 0: kex: server->client enc:aes128-ctr mac:hmac-sha1
*Jun 7 07:49:14.741: %SSH-3-NO_MATCH: No matching kex algorithm found: client curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c server diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
我担心的是是否可以将 RSA 设置为 ubuntu 上的密钥交换方法(ansible 正在使用 sshpass)?
ii sshpass 1.06-1 amd64 Non-interactive ssh password authentication
默认情况下,ansible 使用 OpenSSH,这对旧 IOS 版本有点挑剔。您必须在 ~/.ssh/config 中启用 Diffie–Hellman 密钥交换和一些较旧的密码。
或者,您可以尝试使用 paramiko 进行运输。
虽然这些说明通常适用于 IOS,但我相当肯定您在 IOU 设备上也面临着类似的问题。
资源