Permission denied (publickey) FreeBSD in Google Computer Engine

僤鯓⒐⒋嵵緔 提交于 2020-08-06 06:31:05

问题


I have problems accessing my instance via SSH through the google cloud and also when trying to connect remotely, when trying to connect using the gcloud command on my mac it tells me:

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

The command I am using is the following:

gcloud beta compute --project "my-instance" ssh --zone "server" "freebsd-11-1"

What can it be ?, I import the SSH keys into the metadata of my instance.

I don't know if they affect the permissions of the .ssh folder, I don't know what they are


回答1:


Permission denied with error code 255 can be due to the following reasons:

1.Incorrect user. Make sure to authenticate with appropriate user having the appropriate role in IAM by using the following commands

gcloud auth list

to check active user

gcloud auth login

to log in with appropriate user

2.Issue with keys. Force gcloud to recreate the user’s SSH key pair and try to SSH again. Move the existing key pair aside using these commands:

   mv ~/.ssh/google_compute_engine ~/.ssh/old-google_compute_engine
   mv ~/.ssh/google_compute_engine.pub ~/.ssh/old-google_compute_engine.pub

3.Firewall issue. Check your firewall to see if port 22 is opened for the instance in question.

4.Volume or memory issue. Make sure root volume is not out of disk space or that there are no out of memory issues by going to serial console logs [Menu>Compute Engine>Vm_name>Logs (serial port console)]. You are looking for the following clues

  • No space left on device
  • No usable temporary directory found
  • Out of memory

Increasing the boot disk size or increasing the machine type might help.

5.Linux Guest Environment scripts issue. In order to fix a guest environment issue you may check the following documentation in order to verify the expected output and how to install the required packages.

6.Permission issue. Check folder and Authorized_keys file permissions.

5 and 6 might be difficult to perform if you cannot SSH, however you can log in via serial console this way:

a). Activate the “Connect to serial console” button.

Go to VM instances, click on your VM, Edit, and active “enable connecting to serial ports” in the Remote access area and click on save.

b). Create a username and password.

Go to Vm instance, click on your Vm again, Edit, and fill up the custom metadata section with:

In key: startup-script

In value:

#!/bin/bash  sudo useradd -G sudo pamela sudo echo 'pamela:pamela5' | chpasswd

(This is a script that creates a username : pamela and password: pamela5, which you are going to use later. Please use something else for security purposes. This is only an example. Note that instance might require a reboot for changes to take effect.)



来源:https://stackoverflow.com/questions/57498795/permission-denied-publickey-freebsd-in-google-computer-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!