gpt4 book ai didi

ssh - 可以通过SSH与Cisco IOS一起使用 “authentication failed”消息

转载 作者:行者123 更新时间:2023-12-02 14:08:21 25 4
gpt4 key购买 nike

这是一个非常简单的烦人的案例,使我非常困扰。

这是ansible.cfg的内容:

[defaults]
transport = paramiko
hostfile = ./hosts
host_key_checking = False
timeout = 5

主机的内容,也都包含一个名为“cisco”的用户和一个名为“cisco”的密码
[routers]
R1
R2
R3
...

主机变量文件(R1),类似于R2,R3,...,但IP地址不同:
---
ansible_ssh_host: 10.10.10.1
ansible_ssh_user: cisco
ansible_ssh_pass: cisco

我可以通过linux成功地SSH到那些路由器,但是当我使用ansible时,它导致“身份验证失败”:
fatal: [R1] => {'msg': 'FAILED: Authentication failed.', 'failed': True}
fatal: [R2] => {'msg': 'FAILED: Authentication failed.', 'failed': True}
...

并且我用一些单行ansible命令测试了连通性,即使我手动输入用户名和密码也仍然会出错,例如:
> ansible routers -m raw
R1 | FAILED => FAILED: Authentication failed.
R2 | FAILED => FAILED: Authentication failed.

> ansible routers -u cisco -m raw
R1 | FAILED => FAILED: Authentication failed.
R2 | FAILED => FAILED: Authentication failed.

> ansible routers -u cisco -m raw -k
SSH password:
R1 | FAILED => FAILED: Authentication failed.
R2 | FAILED => FAILED: Authentication failed.

我该如何解决?帮助将不胜感激。

最佳答案

Python解释器connect() for paramiko connections可以这样使用:

connect(hostname, port=22, username=None, password=None, pkey=None, key_filename=None, timeout=None, allow_agent=True, look_for_keys=True, compress=False, sock=None, gss_auth=False, gss_kex=False, gss_deleg_creds=True, gss_host=None, banner_timeout=None, auth_timeout=None)

[…]

look_for_keys (bool) – set to False to disable searching for discoverable private key files in ~/.ssh/

关于ssh - 可以通过SSH与Cisco IOS一起使用 “authentication failed”消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37207474/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com