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

I always left my copy engine instance after a few seconds of inactivity with the indicated error (255). I used "gcloud compute ssh" to login. I am using the default firewall setting, which I believe will be good enough for ssh. But if I am missing something, please indicate and propose correcting this error. Basically, I can’t get any efficient work being done at this moment in order to ssh so many times.

Thanks in advance.

Anh-

+21
source share
11 answers

gcloud denies an ssh connection if a configuration change occurs, for example. after you have changed the default zone or region or created another instance. Then you should update the ssh keys in your metadata using

sudo gcloud compute config-ssh 

If you complain about different entries in your configuration file, where your entries are stored in ssh, ~ / .ssh / config, delete this file and run the above command again.

+30
source

255 is the interactive ssh exit code for ssh failure - otherwise, interactive ssh exits with the exit code of the last command executed in the ssh session.

The next time you get exit code 255 from ssh, try running with --ssh-flag = "- vvv" (more v => more debugging output) and see if it helps to track connection problems.

+13
source

This was my mistake stating that the default firewall will allow all connections to an instance. The converse turned out to be true. See you must set the appropriate firewall rule to allow connection to the instance

An -

+3
source

For those who stop on this page. This helped me solve the problem. Try the following:

  • Go to your Google and delete the SSH key for the server.
  • Run the gcloud command again

It seems that the feature / issue is from the Google Cloud Platform itself, we will continue to test it.

+2
source

This is a real problem with very little documentation to deal with this.

Some time after creating the instance using the gshoud sdk ssh fragment provided through the GCP console, it stopped working and an error constantly occurred when 255 made the connection to ssh in the instance accessible only through the browser through the GCP console for the computation instance in question. Not to mention that this happened to me in many different cases, some of which did not affect the default permissions of the account after the initial setup and deployment, which is too frustrating. Because for no reason it just stops working ... it works, and then it doesn't ...

The only thing that worked for me was creating a new user to communicate through gcloud sdk! Whether it is Windows / PowerShell or Linux locally, using the following snippet:

gcloud compute ssh newuser-name @ instance-name

This is all according to the GCP documentation here: https://cloud.google.com/compute/docs/trouification / troublesho-ssh

Everything else is missing according to the suggestions in the documentation - port 22 is open with access, which means that this should be a problem for users by default authorization_keys, which they provide absolutely no documentation on how to fix it - at least nothing. what I could find upon correction (without creating or deleting)

I tried updating the account, tried to remove the user and credentials from the instance, nothing seems to work. via:

gcloud compute --project "project name" ssh --zone "us-east4-a" "instance name"

It just doesn't work ... - I even tried 'gcloud compute config-ssh --force-key-file-overwrite' DOES NOT WORK ANYTHING ...

But creating a new user works every time, and once the user is created, you can continue to use this user through gcloud sdk

This is a workaround, and I hate circumventing things like this, but for my common sense, it works at least until I can figure out how to reset the default permissions of the account, so if anyone has any ideas or they can show me the direction for which I more than appreciate it!

+1
source

If the default network has been edited or does not use the default network, you may need to explicitly enable ssh access by adding a firewall rule :

 $ gcloud compute firewall-rules create --network=YOUR_NETWORK \ default-allow-ssh --allow tcp:22 

After that, repeat the "gcloud compute ssh" command.

0
source

I had exactly the same symptoms - in my case, the reason was as follows. I used the root user + ssh key, while login was disabled by default in / etc / ssh / sshd_config (PermitRootLogin property).

0
source

I was getting the same error code when trying to login to ssh.

I tried to recreate the ssh key, as mentioned in this answer; However, this did not help.

What works is this:

  • Launch a virtual machine instance from the Google Cloud Console in a browser through Compute Engine -> Virtual Machine Instances, and then
    • select an instance by checking the box and clicking the start button

start by selecting instance

or

  • by clicking on the instance name, you will be taken to the instance page where you click the start button.

start instance on instance page

After successfully starting the instance, you can enter it through the terminal.

I checked it by trying it twice.

0
source

In the end, I had to delete my instance and make a new one with the same drive. See https://cloud.google.com/compute/docs/troubleshooting/troubleshooting-ssh#use_your_disk_on_a_new_instance for details.

0
source

Try sudo with the gcloud command if * nix or Mac is enabled.

-1
source

Maybe this will help someone. I ran into this problem when I was behind my working firewall. As soon as I connected to the public Wi-Fi, everything worked fine.

-5
source

Source: https://habr.com/ru/post/1204004/


All Articles