I'd like to get a file onto my raspberry pi from my google cloud compute engine, but I get the following error:
File "/usr/local/lib/python2.7/dist-packages/paramiko/auth_handler.py", line 212, in wait_for_response
raise e
AttributeError: 'str' object has no attribute 'public_blob'
What does this error message mean?
Thanks in advance!
python file:
import paramiko
hostname = '43.123.231.212'
password = 'passw'
username = 'dosop'
port = 22
gc_path='/home/do//assets/locations.txt'
remotepath='/home/pi/ada.txt'
t = paramiko.Transport((hostname, 22))
t.connect(username=username, password=password, pkey="/home/pi/dos/priv_key"
sftp = paramiko.SFTPClient.from_transport(t)
sftp.get(gc_path, remotepath)
The parameter pkey
, much like hostkey
, expects a value of type PKey
. But you seem to be providing a string to it. You can get a PKey
object out of your private key file by creating an object from paramiko.RSAKey
. The following should help:
import paramiko
hostname = '43.123.231.212'
password = 'passw'
username = 'dosop'
port = 22
gc_path='/home/do//assets/locations.txt'
remotepath='/home/pi/ada.txt'
pk = paramiko.RSAKey.from_private_key(open('/home/pi/dos/priv_key'))
t = paramiko.Transport((hostname, 22))
t.connect(username=username, password=password, pkey=pk)
sftp = paramiko.SFTPClient.from_transport(t)
sftp.get(gc_path, remotepath)
Please note that this assumes you're working with rsa
keys; hence the use of paramiko.RSAKey
.
Also, please keep in mind that if your private key file has a password, you will need to provide the password as a second argument to the function paramiko.RSAKey.from_private_key
, like the following:
pk = paramiko.RSAKey.from_private_key(open('/home/pi/dos/priv_key'), 'password')
I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With