Paramiko SSH 客户端:如何使用公钥认证连接
此示例展示如何使用 paramiko 通过 Python 使用存储在 ~/.ssh/id_ed25519 中的 SSH 密钥连接到 [email protected]:
paramiko_connect_pubkey.py
import os.path
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("192.168.1.112", username="user",
key_filename=os.path.join(os.path.expanduser('~'), ".ssh", "id_ed25519"))另请参阅我们的完整示例:Paramiko SSH 客户端最小示例:如何连接到 SSH 服务器并执行命令
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow