简体   繁体   中英

Permission denied error when ssh to a newly added user in google cloud compute engine

I created a sudo user in a newly created google cloud compute machine (debian) and added a new system user using the below commands

  1. ssh into the instance using this command: gcloud compute ssh instance-name --zone=us-central1-a

  2. created a sudouser by running running this command sudo adduser admin_user

  3. I can see the new user gets added by running the below command less /etc/passwd admin_user:x:1002:1003::/home/admin_user:/bin/sh

  4. The user group also I verified by running groups admin_user . this is the output admin_user: admin_user sudo google-sudoers

But when I try to ssh to that instance from my local machine

gcloud compute ssh --project project_name --zone us-central1-a admin_user@instance-name

its giving the following error.

admin_user@32.29.134.441: Permission denied (publickey).
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].

Could anyone please help how to solve this

The possible causes for a Permission denied (publickey) error are:

  1. Your key expired and Compute Engine deleted your ~/.ssh/authorized_keys file.

  2. You used an SSH key stored in metadata to connect to a VM that has OS Login enabled.

  3. You used an SSH key stored in an OS Login profile to connect to a VM that doesn't have OS Login enabled.

  4. You connected using a third-party tool and your SSH command is misconfigured.

  5. The sshd daemon isn't running or isn't configured properly.

It looks like the first one fits the best for you. To solve this error add the SSH keys as it is explained in this link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM