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()
。沒有必要將路徑拆分成組件並在以後重新組裝。 –