[英]Getting "not a valid RSA private key file" when loading key to Python Paramiko from Key Vault
我正在嘗試連接到在 Synapse 筆記本中使用用戶名、密碼、SSH 密鑰(不需要密碼)的 SFTP。 SSH 密鑰在 Key Vault 中保密。
Host = "sftp.xxxxx.no"
Username = "xxxxx"
Passphrase = "xxxxx"
port = 22
from notebookutils import mssparkutils
SSHkey = mssparkutils.credentials.getSecret('keyvault','SSHkey') #so far has no problem
keydata = b"""AAAAxxx==""" #this is a public key I got through running ssh-keyscan in terminal
key = paramiko.RSAKey(data=decodebytes(keydata))
import io
privkey = io.StringIO(SSHkey)
ki = paramiko.RSAKey.from_private_key(privkey)
cnopts = pysftp.CnOpts()
cnopts.hostkeys.add('sftp.xxxxx.no', 'ssh-rsa', key)
client = pysftp.Connection(host = Host, username = Username, private_key = SSHkey, private_key_pass = Passphrase, cnopts=cnopts)
output = client.listdir()
我的SSHkey
以"ssh-rsa AAAA... "
開頭,以"RF rsa-key-20221126"
。
錯誤消息是:
不是有效的 RSA 私鑰文件
誰能告訴我隧道之光?
您已將公鑰存儲在您的密鑰庫中。 不是私鑰。
您無法使用公鑰進行身份驗證。 您必須將私鑰存儲到保險庫中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.