Powershell: how to set up a public/private key pair

Powershell: how to set up a public/private key pair using Windows and puttygen.exe.

  • Download puttygen.exe, open it and click Generate to generate a private/public key pair. I set the number of key bits to 4096.


  • Then export the private key for use with the SSH-Sessions module (has to be in OpenSSH format – the Putty key format will not work as of 2013-09-14).
    • Use the menu choice Conversions -> Export OpenSSH Key.


# echo 'YOUR KEY HERE' >> /etc/ssh/keys-root/authorized_keys

Then connect specifying the key you exported from puttygen.exe earlier:

PS E:\temp> New-SshSession -Computer -KeyFile E:\temp\esxi-key-openssh.key
            -Username root
Key file specified. Will override password. Trying to read key file...
Successfully connected to
PS E:\temp> Invoke-SshCommand -Computer -Command 'uname -a' -q
VMkernel esxi 5.1.0 #1 SMP Release build-799733 Aug  1 2012 20:03:00 x86_64 GNU/Linux
PS E:\temp>




View all posts by