Python Fabric 的密码验证错误
Password authentication error with Python Fabric
我正在尝试使用 fabric 连接到一些主机,但我收到身份验证错误,尽管我的路由器的用户名和密码是 admin/admin。
g = ThreadingGroup('192.168.255.68', '192.168.254.108', user='admin', port=22, connect_kwargs={'password': 'admin'})
g.run('version')
{<Connection host=192.168.255.68 user=admin>: AuthenticationException('Authentication failed.'), <Connection host=192.168.254.108 user=admin>: AuthenticationException('Authentication failed.')}
启用调试后我看到:
DEBUG:2022-02-21 03:27:12,044:Trying discovered key b'.......4b7dc25cb5d87a6a' in /home/user/.ssh/id_rsa
DEBUG:2022-02-21 03:27:12,087:userauth is OK
INFO:2022-02-21 03:27:12,145:Authentication (publickey) failed.
DEBUG:2022-02-21 03:27:12,186:EOF in transport thread
DEBUG:2022-02-21 03:27:12,187:Encountered exception AuthenticationException('Authentication failed.') in thread for 'thread_worker'
当我特别要求使用密码进行身份验证时,为什么它还要查看 id_rsa 密钥?
通过在 connect_kwargs
中使用“look_for_keys:False”解决了这个问题
我正在尝试使用 fabric 连接到一些主机,但我收到身份验证错误,尽管我的路由器的用户名和密码是 admin/admin。
g = ThreadingGroup('192.168.255.68', '192.168.254.108', user='admin', port=22, connect_kwargs={'password': 'admin'})
g.run('version')
{<Connection host=192.168.255.68 user=admin>: AuthenticationException('Authentication failed.'), <Connection host=192.168.254.108 user=admin>: AuthenticationException('Authentication failed.')}
启用调试后我看到:
DEBUG:2022-02-21 03:27:12,044:Trying discovered key b'.......4b7dc25cb5d87a6a' in /home/user/.ssh/id_rsa
DEBUG:2022-02-21 03:27:12,087:userauth is OK
INFO:2022-02-21 03:27:12,145:Authentication (publickey) failed.
DEBUG:2022-02-21 03:27:12,186:EOF in transport thread
DEBUG:2022-02-21 03:27:12,187:Encountered exception AuthenticationException('Authentication failed.') in thread for 'thread_worker'
当我特别要求使用密码进行身份验证时,为什么它还要查看 id_rsa 密钥?
通过在 connect_kwargs
中使用“look_for_keys:False”解决了这个问题