Setup ssh from PowerShell
-
Open Powershell
-
Type the command:
1ssh-keygen -t rsa -b 4096 -c "Beta Powershell" -
Follow the prompts. Creating a passphrase is optional. Hit enter for no passphrase. It will tell you where your keys are saved.
- Do not close Powershell, you will come back to it
- Navigate to that directory in File Explorer, which should be similar to:
C:\Users\username\.ssh\ - Create a file called config with no extension in this directory.
-
Open that file in a text editor and add the following:
1 2 3
Host raspberrypi HostName raspberrypi.lan User pi -
Replace
raspberrypi.lanon the HostName line with your IP Address if you cannot use that hostname. - Go back to the PowerShell
-
We will need to copy the public key you generated to the pi. Type the following command including the "type" at the beginning
1type $env:USERPROFILE\.ssh\id_rsa.pub | ssh raspberrypi "cat >> .ssh/authorized_keys" -
You should be prompted for the "pi" users password
-
Now, you should be able to type the following command to connect to the RaspberryPi whenever you want:
1ssh raspberrypi -
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 | |
You need to create the .ssh folder and the authorized_keys file:
1 2 3 | |