我正在尝试使用密钥对与 SFTP 服务器建立 SSH 连接。
如果我通过ssh-keygen -t rsa
.
当我通过 Paramiko 连接到服务器时,一切正常:
private_key = paramiko.RSAKey.from_private_key_file("/path/to/my/private/key")
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print("Connecting.")
client.connect(hostname="host.sftp.com", username="user", pkey=private_key)
print("Connected.")
但是,如果我尝试使用 ED25519 密钥执行此操作,则会收到以下错误:
ssh-keygen -t ed25519
File "/usr/local/lib/python3.7/site-packages/paramiko/pkey.py", line 235, in from_private_key_file
key = cls(filename=filename, password=password)
File "/usr/local/lib/python3.7/site-packages/paramiko/rsakey.py", line 55, in __init__
self._from_private_key_file(filename, password)
File "/usr/local/lib/python3.7/site-packages/paramiko/rsakey.py", line 176, in _from_private_key_file
self._decode_key(data)
File "/usr/local/lib/python3.7/site-packages/paramiko/rsakey.py", line 192, in _decode_key
n, e, d, iqmp, q, p = self._uint32_cstruct_unpack(data, "iiiiii")
File "/usr/local/lib/python3.7/site-packages/paramiko/pkey.py", line 529, in _uint32_cstruct_unpack
raise SSHException(str(e))
paramiko.ssh_exception.SSHException: unpack requires a buffer of 4 bytes
我在这里有点不知所措,因为谷歌搜索似乎没有产生任何相关的解决方案。这是内部的错误paramiko
吗?这是我如何初始化我的问题SSHClient
?或者它实际上是一个理论问题(即 ED25519 创建密钥的方式,无法通过低级unpack()
调用读取)?