0
votes

I am unable to access Google VM using Terminal on Mac and browser SSH provided by Google.

On Terminal, it gives me error (when i run sudo gcloud compute ssh instance-name): Permission denied (publickey)

When i try browser SSH, it says: Could not connect, retrying..

What i have tried till now:

  1. Removed all SSH keys of the project from the Cloud console.

  2. Removed SSH key from my system.

  3. Used gcloud init

  4. Ran sudo gcloud compute ssh instance-name and it created a new SSH Key and updated the key to the project key

But it is still giving the same errors.

Please help.

2

2 Answers

0
votes

If you are connecting to VM from your Windows machine, your windows username must be contains just English charackters. I've had such a problem than I change my windows profile, It was fixed.

0
votes

Here is an alternative method that has worked for me:

Create the SSH Key

In the terminal type ssh-keygen -t rsa -f ~/.ssh/{filename} -C {username}

Upload the Public Key to your VM

  1. In the terminal type cat ~/.ssh/{filename}.pub
  2. Copy the results to the clipboard
  3. Back in Google Cloud's Console: Click on your instance name
  4. Click 'Edit'
  5. Scroll down to 'SSH'
  6. Where it says "enter entire key data: Paste
  7. Save

Connect via the Terminal

Type in ssh -i ~/.ssh/{filename}.ppk {username}@{ip-address}