0

有人在 python2.7 中使用 paramiko 模块和 dropbear 成功地进行 ssh 连接吗?执行以下代码时出现“身份验证失败”错误

ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.load_host_keys(os.path.expanduser(os.path.join("~", ".ssh", "known_hosts")))
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("IP", username = "root")

我得到的错误是。

File "/usr/local/lib/python2.7/dist-packages/Qb/QbUnittest/QbUnittest.py", line 624, in __call__
testMethod()
File "testDropBear_send_file.py", line 34, in runMe
    ssh.connect(self.terminal.xmlTerminalCfg.getIp(), username = USER_NAME)
File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 367, in connect
    look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
    File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 584, in _auth
    raise saved_exception
AuthenticationException: Authentication failed.

PS 用户名“root”不需要密码。Dropbear 版本是 2016.73。帕拉米基 1.16. 蟒蛇2.7

4

1 回答 1

0

对于空密码(不用说,在安全性方面不建议这样做),您必须password=""run()调用中明确设置:

ssh.connect("IP",
            username = "root",
            password="",
            look_for_keys=False,
            allow_agent=False)
于 2016-06-15T08:50:46.653 回答