0

I have a google cloud instance that has a program running which creates a file at the end of the run. Now the file that has been created needs to be retrieved to my local machine. I tried the following commands as per this link. My command is as follows

gcloud compute scp root@<instance-name>:~/folder1/folder2/file_name.rds ~/Documents/

After entering the password, I get the following error.

Permission denied (publickey). ERROR: (gcloud.compute.scp) [/usr/bin/scp] exited with return code [1].

I have set Compute Engine to Read Write. Is there anything else I have missed out? Thank you in advance!

adhok
  • 391
  • 2
  • 16

1 Answers1

1

Try to run on your command line first:

gcloud auth login

and then

gcloud beta auth application-default login

Log in with the google account owner of the project

John Balvin Arias
  • 2,632
  • 3
  • 26
  • 41
  • The above commands redirected me to a google login page. After that, I ran the same file transfer command and the error persists. I also tried running the file transfer command without logging into the server via SSH. It gave me the same error `Permission denied (publickey). ERROR: (gcloud.compute.scp) [/usr/bin/scp] exited with return code [1].` Maybe there are some permission issues? – adhok Sep 09 '18 at 12:54
  • Does the account you are log in have permission to access the instance? is it the owner? – John Balvin Arias Sep 09 '18 at 12:57
  • Yes, it does. The account used to create the instance is the owner of the project. – adhok Sep 10 '18 at 17:03
  • I don't know what else could be :/, maybe you misspelled the instance name or didn't configure permissions well – John Balvin Arias Sep 10 '18 at 17:30
  • @adhok, the information provided in this [article](https://stackoverflow.com/questions/44982313/how-to-copy-files-from-google-compute-engine-to-local-directory) appeared to be more detailed. I would also like to mentioned as per [public documentation](https://cloud.google.com/sdk/gcloud/reference/compute/scp) that gcloud compute scp does not work for Windows VMs. I was able to follow this [example](https://cloud.google.com/sdk/gcloud/reference/compute/scp#EXAMPLES) without any issue. Maybe, try this example in a different VM instance. – Sunny J Sep 10 '18 at 21:54