- Generate the private/public keys pair
ssh-keygen -t ecdsa -b 521
- Import public key into your server
cat ~/.ssh/id_ecdsa_rpi.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
-
Make sure the permissions for the private key are correct
- In Windows go to the file properties, remove all permissions and only keep the key owner (https://stackoverflow.com/a/50877382).
- In Linux, run
chmod 600
for the file.
-
Login into the server using the key (with verbose enabled)
ssh -i C:\Users\Fagner\.ssh\id_ecdsa_rpi [email protected] -v
- For future connections you can edit your .ssh/config file to link your private key to your server
Host raspberrypi.lan
HostName raspberrypi.lan
User pi
IdentityFile ~/.ssh/id_ecdsa_rpi
- Then you can connect without the
-i
parameter
ssh [email protected]
- If you configured a passphrase to the private key and you don't want to be prompted every time you connect to the server use
AddKeysToAgent
Host raspberrypi.lan
HostName raspberrypi.lan
User pi
IdentityFile ~/.ssh/id_ecdsa_rpi
AddKeysToAgent yes