How to access to a remote server using Paramiko with a public key-file

只愿长相守 提交于 2019-12-08 04:23:39

问题


I need to connect to a remote server without the use of a password but using a public keyfile using the Python module Paramiko.

How can I do this?


回答1:


Use key_filename argument of SSHClient.connect:

import paramiko

ssh = paramiko.SSHClient()
ssh.connect("example.com", username="user", key_filename="mykeyfile")

Though you need private key file for that. You cannot authenticate with public key file.


You will also need to verify the host key:
Paramiko "Unknown Server"



来源:https://stackoverflow.com/questions/56128059/how-to-access-to-a-remote-server-using-paramiko-with-a-public-key-file

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