一直通过paramiko模块来处理交换机的批量配置,最近换了台客户端[Linux]来连接可以无论如何 都认证不过去总是报错。
[root@zabbix609 backupsw]# python ssh_switch2960.py
Username:admin
Password:
Traceback (most recent call last):
File "ssh_switch2960.py", line 18, in
ssh_client.connect(hostname=ip,username=username,password=password)
File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 446, in connect
passphrase,
File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 764, in _auth
raise saved_exception
paramiko.ssh_exception.AuthenticationException: Authentication failed.
一直报错认证通不过,后来发现是因为近期centos7中了毒后来处理恢复快照到之前时间,可是这个ssh信任密钥认证变更了;
解决方法:
在这个ssh.client.connect(....)后面加入 allow_agent=False,look_for_keys=False
ssh_client.connect(hostname=ip,username=username,password=password,allow_agent=False,look_for_keys=False)
然后再重试就可以了。