Kim Frederiksen
Kim Frederiksen

Reputation: 41

Copying files between instances using gcloud compute scp

I ran into a brick wall with this. I have granted both instances full access: Allow full access to all Cloud APIs.

I am using the following command:

gcloud compute scp [myinstancename]:/var/www  /var/www --recurse --zone europe-west1-d

or

gcloud compute scp root@[myinstancename]:/var/www  /var/www --recurse --zone europe-west1-d

Google Cloud Network Firewall has SSH enabled.

No matter what I have tried, I get the following error:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Thanks in advance.

Upvotes: 2

Views: 1770

Answers (1)

cryotek
cryotek

Reputation: 528

You need to check several things:

  • Have you added/edtited ssh keys to the instance or project metadata? If so, ensure you have the correct public key file in the user's directory of your local machine:

.ssh/google_compute_engine

  • Can you ssh to the instance using the gcloud command?

    gcloud compute ssh [instance_name]
    

You should have installed the gcloud sdk, the official way to install it is detailed in Google Cloud docs here:

Installing Cloud SDK

If you never ran a gcloud command in your local machine, you need to initialize it by running:

gcloud init
  • If you still can not ssh to the instance from your local machine, ensure you have the public key file in the user's directory:

It would help if you run the gcloud ssh with some debug flags:

gcloud compute ssh [instance_name] --log-http --verbosity debug
  • Compute Engine API quota. Usually this shouldn't be changed but it could be that someone else by mistake limited the max requests to the API.

Upvotes: 1

Related Questions