Tomorrows Technology Today

How To

How to copy ssh keys in Windows PowerShell

Windows powershell does not include the ssh-copy-id command that you find on linux hosts. So in order to copy an ssh key from your Windows PowerShell to your linux host, you can use the following nifty oneliner from inside your .ssh directory.

cat id_rsa.pub | ssh user@myremotehost.com "cat >> .ssh/authorized_keys"

if you look step by step, you can see it prints out the public key and then pipes that as input to ssh. The second cat command with the >> means the key will be appended to your authorized_keys file on your remote host

Leave a Reply

Your email address will not be published. Required fields are marked *