首页 文章

通过SSH向Cisco IOS发送“身份验证失败”消息

提问于
浏览
2

这是一个非常简单的ansible案例,困扰了我很多 .

这是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.

我怎么解决这个问题?帮助将不胜感激 .

1 回答

  • 0

    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 =无)[...] look_for_keys(bool) - 设置为False以禁用在〜/ .ssh /中搜索可发现的私钥文件

相关问题