Paramiko Protocol error: expected packet SSH_MSG_USERAUTH_REQUEST, got SSH_MSG_SERVICE_REQUEST

对着背影说爱祢 提交于 2019-11-29 15:20:07

TL;DR: Add this: allow_agent=False and/or look_for_keys=False to your connect() call.

Doing some research on this, I have come to the conclusion that public key auth by a Paramiko SSH client doesn't always work with all SSH servers. I was trying to connect to a Cisco ASA device. The relevant part of the error log was:

DEBUG:paramiko.transport:Switch to new keys ...
DEBUG:paramiko.transport:Trying SSH agent key 5d081d52f889f2c224606d6b2065606e
DEBUG:paramiko.transport:userauth is OK
DEBUG:paramiko.transport:Authentication type (publickey) not permitted.
DEBUG:paramiko.transport:Allowed methods: ['password']
INFO:paramiko.transport:Disconnect (code 2): Protocol error: expected packet type 50, got 5

Notice the 'Trying SSH agent key...' part? I didn't want that, I wanted to force password auth. Where the OpenSSH interactive client either falls back gracefully from publickey to password, paramiko doesn't, forcing it to use user/pass authentication fixed the issue for me, it might work for you.

I don't know if this is a paramiko bug or a bug on the SSH server. Paramiko does fall back from publickey to password or keyboard-interactive when talking to an OpenSSH server.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!