Reputation: 639
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
Upvotes: 8
Views: 2710
Reputation: 36649
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?
Upvotes: 6
Reputation: 76
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
Upvotes: 6