VS Code SSH Key Path

The Simplest Thing Can Sometimes Be Hard

A key.

I'm no dummy. I know how to google a thing. But I struggled to solve this simple problem regardless of the fact that I have the entire Internet at my disposal.

I use VS Code on both Linux and Windows. I use an extension called SSH FS to access the file systems on the various Pi's around here. Sometimes I'm editing from a Windows machine, sometimes from a Linux machine. Just depends.

I really like the SSH FS extension for VS Code. I have SSH keys configured so I can do passwordless logins inside my network.

The problem was when I switched from Linux to Windows or vice versa I would get an error that said:

Error while connecting to SSH FS zeroone: Error while reading the keyfile at: /.ssh/id_rsa

I would then have to re-configure this setting in the SSH FS extension every time. The config setting suggested one or the other system variable, which was dependent on which platform I was on.

SSH FS config for setting the path to my keys.

I knew if I could set a system variable on one platform to point to my home folder in a way that mimicked the other platform's system variable, I'd be good.

Linux uses a system variable called HOME, while the Windows way of doing it is with a system variable called USERPROFILE.

I thought it would be easy to do. I googled it. Lots of advice on how to get it done, but no clear example of the actual 'spelling' of the variable. I saw Windows system variables spelled $VARIABLE$, and $VARIABLE in different posts on multiple blogs and forums. As a result, I initially tried creating the variable spelled like that. Finally I figured out I should leave off the $ altogether. That's way too simple. But not totally obvious to me.

It shouldn't be that hard.

I needed to create a new system variable called HOME that pointed to my user home directory. There is no system variable called HOME in Windows by default.

So here is a photo gallery with all the pertinent details:

The captions provide some good hints.

Once I set the HOME system variable in my Windows machines, the SSH FS extension was happy, and now I'm happy.

And once again, VS Code is a Thing That Works!

link to home page

links