Difference between the commands "gcloud compute ssh" and "ssh"
Asked Answered
G

2

8

What exactly is the difference between the gcloud compute ssh comannd and "just" the ssh command?

I made the observation that even so I can easily connect between two instances using gcloud compute ssh, i cannot do it with the ssh command. However, after setting up the ssh-keys manually, the ssh command works fine. But shouldn't the gcloud command handle the key management? And if it is set up one time using gcloud, why is the ssh command not working properly

.

Works fine:

gcloud compute ssh instance_2
gcloud compute shh instance_1

.

Doesn't work without manually setting up the ssh-keys:

ssh instance_2
shh instance_1

.

This question comes from a different problem I had, which drove me nuts for days: OpenMPI: Permission denied error while trying to use mpirun

Gautious answered 17/3, 2016 at 13:33 Comment(0)
R
6

gcloud compute ssh installs the key pair as ~/.ssh/google_compute_engine[.pub]. ssh uses ~/.ssh/identity[.pub] by default.

You can either copy the google key pair to the default name:

$ cp ~/.ssh/google_compute_engine ~/.ssh/identity
$ cp ~/.ssh/google_compute_engine.pub ~/.ssh/identity.pub

or you can just specify the private key to use when you invoke ssh:

$ ssh -i ~/.ssh/google_compute_engine instance_name
Roccoroch answered 17/3, 2016 at 15:55 Comment(0)
D
6

The dedicated google command gcloud compute ssh instance basically uses the standard ssh under the hood, but does some magic on top, e.g. installing the keys. It is quite well explained in the answer to this question: How to get the ssh keys for a new Google Compute Engine instance?

Deformation answered 18/3, 2016 at 14:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.