为了账号安全,请及时绑定邮箱和手机立即绑定

paramiko加载私钥文件报错

paramiko加载私钥文件报错

慕姐3215275 2019-03-29 16:10:34
代码是:import paramiko private_key = paramiko.RSAKey.from_private_key_file('/Users/username/.ssh/id_rsa')私钥文件是openssh的:$ cat id_rsa -----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEA(略)使用私钥+secureCrt可以正常登录;但是python里这一行就会报错,提示rsa文件错误。Traceback (most recent call last):   File "/Users/tianyawei/PycharmProjects/protocolTest/CUAdapterV1/AdapterMachine/MyMachine.py", line 11, in <module>     private_key = paramiko.RSAKey.from_private_key_file('/Users/tianyawei/.ssh/id_rsa', 'tianyawei@sunseaaiot.com')   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/paramiko/pkey.py", line 206, in from_private_key_file     key = cls(filename=filename, password=password)   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/paramiko/rsakey.py", line 55, in __init__     self._from_private_key_file(filename, password)   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/paramiko/rsakey.py", line 175, in _from_private_key_file     data = self._read_private_key_file("RSA", filename, password)   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/paramiko/pkey.py", line 279, in _read_private_key_file     data = self._read_private_key(tag, f, password)   File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/paramiko/pkey.py", line 289, in _read_private_key     raise SSHException("not a valid " + tag + " private key file") paramiko.ssh_exception.SSHException: not a valid RSA private key file找了很多方法都不对,有人知道吗。。。
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 2820 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信