开发者

how to get past keyboard authentication with paramiko [duplicate]

This question already has an answer here: Password authentication in Python Paramiko fails, but same credentials work in SSH/SFTP client (1 answer) 开发者_如何学Python Closed 3 years ago.

I am trying to use Paramiko to connect to a remote host via ssh however I get an error message which states that keyboard authentication is required to access the host. Is there any way I can get around this using Paramiko? If not, is there another ssh module I can use? I'll even use another language if I have to. The only thing I can't do is change the settings on the host. Also, I am writing this application on a Windows host so pxssh is not an option. Any suggestions?


You could get username and password from whatever resource you have and use it when calling connect. For example you could save them in a config file.


Either pass the private key directly using pkey= or pass in the name of the file with key_filename= when calling connect() like so:

client = SSHClient()
client.connect('remotehost', key_filename='/path/to/private_key')

or

private_key = """
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIMhTkzF8pZ5gtXvAafjNRsKXWXnhjslUW194WteddA3YoAoGCCqGSM49
AwEHoUQDQgAEkb0qngPKOKVcjqszHg+7Y95TLvWZb5qtHb4ZmuLJRYIMzx78C9gp
sb3jBuW2VCaoO8SfyXUKeOzT7eJTH6j8GQ==
-----END EC PRIVATE KEY-----
""""
client = SSHClient()
client.connect('remotehost', pkey=private_key)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜