Unable to ssh to google cloud instance which is created from the OVa

Viewed 466

I have created a google cloud instance from the custom OVA by using the following command:

gcloud beta compute instances import instance --source-uri=gs://abc/xyz.ova --os=centos-7

In the VM which I used to create the OVA ssh is enabled on port 22.

Unfortunately, I am unable to ssh to the instance created. In gcp firewall ssh port 22 is enabled I am getting the following error while trying to ssh.

ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].

I couldn't get the exact reason.

1 Answers
  1. Wait for a few minutes and try again. It is possible that:

    a. The instance has not finished starting up, or that the SSH session was terminated.

    b. Metadata for SSH keys has not finished being propagated to the project or instance.

    c. The Google Agent has not yet read the SSH keys metadata.

  2. Make sure that the user has authenticated to gcloud as an IAM user with the compute instance admin role; for example, run gcloud auth revoke --all, gcloud auth login <iam-user> then try gcloud compute ssh again.

  3. Logon using UI ssh. This creates an ephemeral ssh key, Google Agent also executes the code path to refresh .ssh/authorized_keys and address any invalid dir/file permissions for both .ssh/ and .ssh/authorized_keys. This approach will address common gcloud compute ssh issues that relate to corrupted keys, missing dir/file or invalid dir/file permission. Try the gcloud again after performing the UI ssh.

  4. Make sure that the root volume is not out of disk space.

  5. Make sure that the instance has not run out of memory.

  6. Verify that persistent SSH Keys metadata for gcloud is set for either the project or instance.

Managing SSH keys in metadata: https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys

  1. Verify that the Linux Google Agent scripts are installed and running. See Determining Google Agent Status. If the Linux Google Agent is not installed, reinstall it. See below Guest Agent Installation guide.

Guest Agent Installation : https://cloud.google.com/compute/docs/images/install-guest-environment

  1. Check for the Authentication issues are logged in to /var/log/auth*.log, review this log for any errors. If this file can't be accessed due to inability to logon to the VM, this requires detaching and attaching the boot disk to another VM in order to review the logs.
Related