Sharing SSH keys between Ubuntu on Windows and Windows 10

I’ve got a handful of Ubuntu VPS’s on DigitalOcean. This is all part of my effort to teach myself how to admin and eventually develop for that OS. So far I’ve got a WordPress site (this one), a node box and an ELK box to monitor them.

When I’m working at home in my office I’m running Windows 10. When I’m camped in front of the TV with my wife, I’m on a Chromebook with Crouton and Ubuntu. The first thing I notice is that the workflow between the two is quite different. Putty and FileZilla on the one, straight Bash on the other.

I’m not ready (nor will I likely ever be) ready to switch to Linux for everything so I’m going to try to get the to environments to feel the same.

If you’re a Windows guy like me, but interacting with Linux machines, you probably started with PUTTY to generate ssh keys and are using it for secure shell. Another option is now Bash on Ubuntu for Windows (aka the Windows Subsystem for Linux), which I’ve just started to play with.

The nice thing about it is that it’s, well…, Linux. Everything (I’m sure not everything but you get the point) just works the same. No need to SSH to a remote machine just to start running some Bash scripts. No PAgent. No PUTTY. Just pop open Bash right on your Windows box and away you go.

Converting and Sharing PuttyGen SSH Keys with the Linux Environment

Since I’ve already got a private key for my Windows box, and don’t really want a new one for the Linux environment, it’s also possible to share the same key between environments.

A couple of stackexchange posts help immensely there. I want to keep my keys all in one spot, so directions on how to convert a PuttyGen key and share them with the Ubuntu environment made that a snap.

  • Open your private key with PuttyGen
  • Export it to a file named id_rsa in the same location as the ppk file. (Conversions->Export OpenSSH)
  • From Bash on Ubuntu for Windows execute the following (assuming that your private key is in .ssh in the root user location on Windows):
ssh-keygen -e -f /mnt/c/Users/UserName/.ssh/id_rsa > /mnt/c/Users/UserName/.ssh/
ssh-keygen -i -f /mnt/c/Users/UserName/.ssh/ > /mnt/c/UserName/.ssh/
ln -s /mnt/c/Users/UserName/.ssh/id_rsa ~/.ssh/id_rsa
ln -s /mnt/c/Users/UserName/.ssh/ ~/.ssh/
chmod 600 ~/.ssh/id_rsa

This will convert the PuttyGen key to OpenSSH format and link it from the Windows file system to the Linux home location.


Leave a Reply