SSH Quirks

When trying to update my Ghost installation, I realized I had set up a new ssh key.. which meant I didn't know if I had the ssh key for the server.  Oops.

Digging through my backups, I found my ssh file, and copied it to my computer. I found a command for ssh where you can specify a different key.

ssh -i <keyfilepath> login@location

However, when I tried this, I got an interesting error.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0777 for 'id_rsa' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. Load key "id_rsa": bad permissions

I use Windows to develop. Don't @ me about it. If you generally write C#, Windows is the way to go. Someday maybe the Visual Studio tooling will be better on Mac or Linux, but until that happens, I'll be on Windows. However, there are cases where Linux is better, for sure. Running Docker instances, doing terminal/ssh things, things along those lines.. so I'm not a Linux hater either. Generally I code toward Windows for client side and Linux for backend.

I was using WSL2, with Ubuntu on top of it, to do my ssh. For those of you that don't know, WSL2 is a way to virtualize Linux on top of windows, so that you can have an instance at your fingertips.

In WSL2, Windows files show up as /mnt/c, which is great, access to your files but from within (in my case) Ubuntu. Unfortunately, the way it mounts those folders is with 777 permissions – basically god mode for files in Linux.

To solve this problem, I had to move the files to my home directory. thankfully this is easy.

cp <path-to-my-ssh-folder-I-need> ~/.otherssh -r

Now, in Ubuntu, I had to fix its permissions.

cd ~/.otherssh chmod 600 id_rsa <or whatever your private key is called>

And now, happily, ssh started working properly

ssh -i id_rsa login@location Enter passphrase for key 'id_rsa': Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-101-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage
Previous
Previous

Digital Cruft, Part 1

Next
Next

Getting Started (and Restarting)