Skip to content

Setup ssh from PowerShell

  1. Open Powershell

  2. Type the command:

    1
    ssh-keygen -t rsa -b 4096 -c "Beta Powershell"
    
  3. Follow the prompts. Creating a passphrase is optional. Hit enter for no passphrase. It will tell you where your keys are saved.

  4. Do not close Powershell, you will come back to it
  5. Navigate to that directory in File Explorer, which should be similar to: C:\Users\username\.ssh\
  6. Create a file called config with no extension in this directory.
  7. Open that file in a text editor and add the following:

    1
    2
    3
    Host raspberrypi
        HostName raspberrypi.lan
        User pi
    
  8. Replace raspberrypi.lan on the HostName line with your IP Address if you cannot use that hostname.

  9. Go back to the PowerShell
  10. We will need to copy the public key you generated to the pi. Type the following command including the "type" at the beginning

    1
    type $env:USERPROFILE\.ssh\id_rsa.pub | ssh raspberrypi "cat >> .ssh/authorized_keys"
    
  11. You should be prompted for the "pi" users password

  12. Now, you should be able to type the following command to connect to the RaspberryPi whenever you want:

    1
    ssh raspberrypi
    
  13. If you set an optional passphrase for the key back in step 3, you'll be prompted for it

Troubleshooting#

If you receive the error:

1
bash: /home/user/.ssh/authorized_keys: No such file or directory

You need to create the .ssh folder and the authorized_keys file:

1
2
3
mkdir ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys

Last update: 2022-02-13 14:08:25