Actually I already have tried everything as dicussed in SSH Permission denied (publickey) and Unable to ssh to GCE: “Permission denied (publickey), But none resolved the issue.

I am able to ssh into root account, but not the account I used to login in.

I did try the following things to get it fixed from ROOT Account.

  1. sudo chown -R $USER ~/.config/gcloud
  2. Generate ssh key using the following commands

    • ssh-keygen
    • Copy the key.pub file contents
    • Append the contents to ~/.ssh/authorized_keys file
    • sudo nano ~/.ssh/authorized_keys

I have set up Google cloud Virtual Machine Instance with Ubuntu 16.04 LTS. I usually use to ssh my machine with the following command:

gcloud compute --project "XXX-XXX" ssh --zone "us-east1-b" "XXXXXXXX"

But now when try it, it gives the following error:

Permission denied, please try again.

I have three accounts on virtual machine. One root, abdullah, mrafique.bese_17seecs. My whole virtual environments are existing in 'abdullah', which I cannot access right now.

Please help.

  • 1
    Could be a SSH version difference but if you say root worked it's unlikely, or there may be a filter on "AllowUsers" setting. Make sure the other user account is allowed to SSH.
    – Overmind
    Mar 14, 2019 at 7:07
  • I used su - abdullah and it worked completely fine after logging as root. Thanks Mar 14, 2019 at 7:13

2 Answers 2


If you entered the commands as you posted them as the root account, you did nothing at all with your login user. You only modified files in the home directory of the root user. Instead of ~ (which expands to the home of the logged in user) you have to use ~abdullah or /home/abdullah (if that is the home directory) in these commands.

  1. chown -R $USER ~abdullah/.config/gcloud
  2. Generate ssh key using

  3. Copy the key.pub file contents
    nano ~abdullah/.ssh/authorized_keys

And you don't need sudo when you are already root.

  • Thanks!, But when I do ' chown -R $USER ~abdullah/.config/gcloud ' It gives the following error ' chown: cannot access '/home/abdullah/.config/gcloud': No such file or directory '. Mar 14, 2019 at 7:38

I don't know how, but following this answer, after I logged in as root I issued:

su - abdullah

I got logged with my own account, and I can run anything as before.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .