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

gcloud compute config-ssh
commanderror usr bin ssh exited with return code 255
gcloud compute ssh not working
gcloud compute ssh verbose
error: (gcloud compute ssh your platform does not support ssh)
gcloud compute ssh ssh key
gcloud compute ssh documentation
gcloud compute ssh quiet

I kept getting kicked out of my compute engine instance after a few seconds of idle with the indicated error (255). I used 'gcloud compute ssh' to log in. I am using the default firewall setting, which I believe would be good enough for ssh. But if I am missing something, please so indicate and suggest the fix for this error. Basically I can't get any efficient work done at this point having to ssh in so many times.

Thanks in advance.


gcloud denies an ssh connection if there was a change in the setup, e.g. after you changed your default zone or region, or you created another instance. Then, you must update the ssh keys in your metadata by

sudo gcloud compute config-ssh

If this complains about different entries in your config file where your ssh key entries are stored, ~/.ssh/config, delete this file and execute the above command again.

Gcloud compute ssh fails with return code [255] - General, If you have installed gcloud without sudo, you can omit sudo . 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. mv ~/.ssh/ ~/.ssh/ mv ~/.ssh/google_compute_engine ~/.ssh/google_compute_engine.old. Try gcloud compute ssh [INSTANCE-NAME] again. A new keypair will be created and the public key will be added to the SSH keys metadata. Verify that the Linux Guest Environment scripts are installed and

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's => more debugging output) and see if it helps track down connection problems.

SSH Error, return 255, gcloud compute --project "" ssh --zone "us-central1-a" ERROR: (gcloud.​compute.ssh) [/usr/bin/ssh] exited with return code [255]  Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

IT was my mistake stating that the default firewall would allow all connections into an instance. The contrary turned out to be true. Please refer to an appropriate firewall rule must be set up to allow connection into an instance


(gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255], gcloud compute ssh "tomcat-01". Permission denied (publickey). ERROR: (​gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. ssh: connect to host port 22: Connection refused ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. I should add that I could access ssh until today, and of course, I did authentication before with gcloud auth login

problems reconnecting to datalab (ERROR: (gcloud.compute.ssh , (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255] Error: Disconnected: No supported authentication methods available (server  gcloud compute ssh --zone=us-central1-c datalab@kvnewdatlab ssh: connect to host port 22: Connection timed out ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255] As you said, there is probably an issue with gcloud SSH'ing into the VM.

This is a real problem with very little documentation to dealing with it.

Sometime after creating the instance using the gcloud sdk ssh snippet provided via GCP console stopped working and continually errors with 255 making connecting to ssh on the instance only available through browser via GCP console for the compute instance in question. Not to mention this has happened to me on many different instances some without touching the default account permissions after initial setup and deployment which is overly frustrating. Cause for no reason it just stops, then doesn't...

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

gcloud compute ssh newuser-name@instance-name

That all per GCP documentation here:

Everything else passed per suggestions in documentation - port 22 open with access meaning it has to be a a problem with the default users authorization_keys WHICH they provide absolutely no documentation on how to fix that - at least nothing I could find on fixing (not creating or deleting)

I've tried updating the account, tried deleting the user and credentials from the instance, nothing appears to work. using:

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

Just doesn't work... - even tried 'gcloud compute config-ssh --force-key-file-overwrite' NOTHING WORKS...

But creating a new user works every time, and once the user is created you can keep using that user via gcloud sdk

It's a work around, and I hate work around's for things like this but for my sanity this works at least until I can figure out how to reset the default account permissions, so if anyone has any ideas there or can point me in a direction for that I'd more than appreciate it!

SSH Just stops working at sometimes : googlecloud, ssh) [/usr/bin/ssh] exited with return code [255]. Connection broken. Attempting to reconnect My gcloud version: Google Cloud SDK 207.0.0 ojarjur changed the title ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. File permissions for the `datalab` user getting corrupted, which blocks the `datalab connect` command from working. Aug 23, 2018

ERROR: (gcloud.compute.ssh), ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. I'm really confused EDIT: How to fix: Just increase the disk space of the instance. Nestor Urquiza is a hands-on technologist, security-first thinker and results-oriented business executive. An Electronic Engineer dealing with hardware, embedded/web software development, security, compliance and full business funnel process engineering.

Error while trying to ssh into Linux VM on GCP, ssh) [/usr/bin/ssh] exited with return code [255]. Getting this error after upgrading a VM: $ gcloud compute ssh myvm -- -vvv OpenSSH_***,  go to the 'ssh keys' section, and add ssh key from local machine '~/.ssh/'. I usually just copy and paste the contents of the file to the web interface. The ssh key will have 'user@host' on the end, edit this to just have the username you require, leave off the @host portion. save (you may need to restart also, but try without first).

GCE VM not connecting from Terminal but working in Web SSH , Permission denied (publickey,gssapi-keyex,gssapi-with-mic). ERROR: (gcloud.​compute.ssh) [/usr/bin/ssh] exited with return code [255]. share. Share a link to  ssh: connect to host port 22: Connection refused ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255]. The weird thing is that this worked for me the first time I went through but now it doesn't. Any suggestions?

  • This w/o the sudo fixed the above issue for me at least.
  • Saved my life, worked for 7 hours without solution, just a single command did the trick.
  • This worked for me in a similar issue.
  • after using nmap IPaddress, the output is : Nmap scan report for (IPaddress) Host is up (0.074s latency). Not shown: 994 filtered ports PORT STATE SERVICE 22/tcp closed ssh 80/tcp closed http 443/tcp closed https 3389/tcp closed ms-wbt-server 6000/tcp closed X11 7000/tcp closed afs3-fileserver Nmap done: 1 IP address (1 host up) scanned in 7.32 seconds The STATE for PORT: 22/tcp is closed, what to do in this matter, any suggestions?
  • Please post information as comment instead of answes.
  • hi Jacob - i actually tried, sadly my profile (beginner) does not allow me to add a comment to the answer posted above (with best rate) :/ ... "Once you have sufficient reputation you will be able to comment on any post"