Skip to main content

Ubuntu 20.04 - Unable to login into GCloud via CLI SSH after Ubuntu 20.04 Upgrade

TLDR;


cp -prf ~/.ssh /tmp/.ssh_2024_02_24
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*


I had this curious issue, where my perfectly fine GCloud SSH Login via CLI stopped working when I moved from Ubuntu 18 to Ubuntu 20.


The error I was was not very descriptive, even when running verbose


gcloud --project=my-project compute ssh my-server-01  --zone=asia-south1-c --internal-ip

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


Verbose mode ( not including output for brevity ) :


gcloud --project=my-project compute ssh my-server-01  --zone=asia-south1-c --internal-ip --verbosity=debug


Now, this happened twice with me. Once when I upgraded! And second when I used a laptop freshly installed with Ubuntu 20.

The first time it happened, I assumed something broke in the upgrade and reinstalled the OS since it was already on a different partition. Still no luck. The final solution was to downgrade to Ubuntu 18.

2nd time around, I was more determined to find the cause. I figured out it was due to OpenSSH becoming more strict, but I didn't have the option to downgrade it.  I tried adding options to openssl config, hoping to use a less latest version  of TLS. Nope, no success!

And after lot of search, I ended up on a stackoverflow.com page, which mentioned that it could be a case of .ssh files not having secure permissions and the SSH error message being insufficient misleading .

So, I crossed my fingers and did as suggested,

cp -prf ~/.ssh /tmp/.ssh_2024_02_24
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*

And that solved it!




Comments

Popular posts from this blog

Formatting JSON in Kate - KDE Editor

Some years ago, I wrote a post on Formatting XML in Kate - KDE Editor . This one  below is for JSON format. Like the XML one this one also makes use of a tool installed on your machine and is invoked from Kate as a filter. TLDR;   Kate  is one awesome editor ( If you don't like  Vim  for its 'CLI'ness ) When working from the command line we can use a handy tool ' jq ' to format JSON files and pretty print them. Well, the good news is we can use the same from within Kate  as well But it is a tedious task to use it when you have some content in  Kate  ( more so if it is an unsaved file ) and want to format it. Incase, you don't have  jq  installed, simply hit sudo apt-get install jq and that will install it for you. If you use  jq  you would do something like this, Save File (  MySavedFile.xml  ) Go to Command Line cat MySavedFile.txt | jq '.' - > MySavedFile.txt and then reload our file in  Kate . If you wish t...

Formatting XML in Kate - KDE Editor

TLDR;   Kate is one awesome editor ( If you don't like Vim for its 'CLI'ness ) When working from the command line we can use a handy tool ' xmllint ' to format XML files using its --format option. But it is a tedious task to use it when you have some content in Kate ( more so if it is an unsaved file ) and want to format it. Incase, you don't have xmllint installed, simply hit sudo apt-get install libxml2-utils and that will install it for you. If you use xmllint you would do something like this, Save File ( MySavedFile.xml ) Go to Command Line cat MySavedFile.txt | xmllint --format - > MySavedFile.txt and then reload our file in Kate . If you wish to remain in Kate and get this done then you would need to do, Select text ( Complete or Partial ) Hit ' Ctrl + \ '  or go to Tools -> Filter Text Incase your Kate does not have the option for 'Filter Text' under tools, you just need to enable the 'Text F...

Set default profile for Konsole on Ubuntu

The option for changing the default profile is not present in konsole (atleast not in Ubuntu 12.04 LTS). It is really irritating to switch profiles whenever I open a new tab. However, we can change it via the config file. The config file is usually present in the home folder /home/username/.kde/share/config/konsolerc It will look something like this, [$Version] update_info=konsole.upd:2.9.0-global-options [Colors] CurrentPalette=Forty Colors [Desktop Entry] DefaultProfile=NewDawn.profile [Favorite Profiles] Favorites=/home/username/.kde/share/apps/konsole/Shell.profile,/home/username/.kde/share/apps/konsole/NewDawn.profile [MainWindow] Height 900=901 State=AAAA/wAAAAD9AAAAAAAABf8AAANQAAAABAAAAAQAAAAIAAAACPwAAAAA ToolBarsMovable=Disabled Width 1600=1601 You can see in Favorite Profiles, I have added a profile named NewDawn apart from the default one named as Shell. My default profile was Shell.profile which I changed to NewDawn.profile by changing Defaul...