0
我米使用的是Mac,并增加了对桌面RSA密钥错误的RSA密钥的paramiko LIB
我使用的路径是
host_key = paramiko.RSAKey(filename='~/Desktop/test_rsa.key')
错误:
Traceback (most recent call last):
File "/Users/vidit/PycharmProjects/untitled6/server.py", line 7, in <module>
host_key = paramiko.RSAKey(filename='~/Desktop/test_rsa.key')
File "/Library/Python/2.7/site-packages/paramiko/rsakey.py", line 45, in __init__
self._from_private_key_file(filename, password)
File "/Library/Python/2.7/site-packages/paramiko/rsakey.py", line 163, in _from_private_key_file
data = self._read_private_key_file('RSA', filename, password)
File "/Library/Python/2.7/site-packages/paramiko/pkey.py", line 267, in _read_private_key_file
with open(filename, 'r') as f:
IOError: [Errno 2] No such file or directory: '~/Desktop/test_rsa.key'
'expanduser()'可以直接使用,如果路径与'〜'开始可以使用
expanduser()
。没有必要将路径拆分成组件并在以后重新组装。 –