Beginners guide to SSH keys in PowerShell

As Microsoft continues to add feature after feature to the PowerShell experience, the number of things available to a beginner can be overwhelming.
But fear not, the simplicity awarded by using SSH keys is something you shouldn't miss out on if you spend any amount of time on a Linux machine.

Table of Contents

  • Generating a keys
  • The SSH folder
  • Copying your key to another computer

Generating keys

Generating an SSH key pair is frankly a piece of piss, and you're not likely to do it very often, enter ssh-keygen then press the enter key at the prompts until it's finished

You cannot lose

The SSH folder

Now that the key pair is created, we can break down the contents of the SSH folder, which is created within your userprofile folder by default.

The SSH folder
  • id_rsa : This is your 'private key' which I've written in Italic so that you know it's a secret and not really for sharing.
  • id_rsa.pub : This one is the public key, as evidenced by the .pub extension - it's the one that gets copied to other computers.
  • known_hosts : This file keeps track of the different signatures of computers you've connected to in the past so you can't be bamboozled by a threatening actor

Copying your key to another computer

SSH is a ultimately a fairly simple exchange of data.

The host you're trying to connect to provides a bit of data that only the private key could encrypt, your machine does that then you and the remote host compare hashes for the encrypted data.

Typically it's not hard to get a file from one computer to another, and in many implementations of the SSH client you can copy your key to a remote computer with a single command: ssh-copy-id

This utility unfortunately does not presently exist in the Windows OpenSSH. My implementation of the tool is as below:

Rory Maher

Rory Maher