1

I'm trying to use scp to copy a large file over to cloud shell.

Using the suggested command from this SO answer

gcloud alpha cloud-shell scp \ localhost:~/Sites/my-app/big_file cloudshell:~/big_file 

But even though I can see it adding a key for the server, it fails with Permission denied (publickey).

If I do

gcloud alpha cloud-shell ssh 

it logs in to the server just fine

2 Answers 2

2

Turns out google's invocation of scp was omitting the correct username.

Solution I successfully uploaded by doing

/usr/bin/scp -P 6000 -i /Users/me/.ssh/google_compute_engine -o \ StrictHostKeyChecking=no ~/Sites/my-app/bigfile \ [email protected]:~/big_file 

How to figure this out

I was able to discover this using the --verbosity debug flag

# gcloud alpha cloud-shell scp --verbosity debug localhost:~/Sites/my-app/big_file cloudshell:~/big_file DEBUG: Running [gcloud.alpha.cloud-shell.scp] with arguments: [(cloudshell|localhost):DEST: "cloudshell:~/big_file", (cloudshell|localhost):SRC:1: "['localhost:~/Sites/my-app/big_file']", --verbosity: "debug"] DEBUG: Running command [/usr/bin/scp -P 6000 -i /Users/chrisjensen/.ssh/google_compute_engine -o StrictHostKeyChecking=no ~/Sites/my-app/big_file 35.185.184.136:~/big_file]. [...more debug info...] 

^ This is the line that shows the command that was run

Then I ran ssh to see if there was a difference in the arguments

gcloud alpha cloud-shell ssh --verbosity debug DEBUG: Running [gcloud.alpha.cloud-shell.ssh] with arguments: [--verbosity: "debug"] DEBUG: Running command [/usr/bin/ssh -t -p 6000 -i /Users/chrisjensen/.ssh/google_compute_engine -o StrictHostKeyChecking=no [email protected]]. [...more debug info...] 

^ Notice it prepends by username to the server ip.

So then I copied the scp command and added my username, and it worked a charm.

Hope this helps others trying to figure this out.

1

This should be fixed in the latest version of gcloud, which you can get by runnign gcloud components update. Thanks for trying the alpha!

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.