-
Notifications
You must be signed in to change notification settings - Fork 1
K. Passwordless
This chapter will be a short one, but highly important because it saves us a lot of time⏳, not having to always insert your password when SSH-ing to your Raspberry Pi🥧.
-
But is it secure?
-
Yes, it's a RSA encryption.
-
How are we going to do this?
-
Simple, we will generate an public key, that our raspberry will know and will use to authenticate our connection. The authentication key must be appended to remove hosts
~/.ssh/authorized_key
file.
We have to keep in mind that we will ssh
from local-host
(in this case my Macbook) to remote-host
(Raspberry Pi 4).
I already have a public key, I checked this by moving to .ssh
directory and running ls -l
.
The .ssh file is located in your user directory : /home/username/.ssh
.
If you don't have it, we must create a public key on our local-host
.
$ ssh-keygen -t rsa -b 4096
Then:
-
[Enter key]
-
[Enter key]
-
[Enter key]
$ Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub.
!! Make sure to specify your username when trying to copy the key over, if you have a different user (which you most probably due) it will not work.
$ ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
Proof: 💪🏼
**Congrats, you're done!**
This must be done on our remote-host
.
In order to remove an authorization key you can use any text editor and simply edit the authorized_keys file from .ssh directory.
In my example, I used vi
* authorized_keys -> i to edit -> delete text of previous installed key -> ESC -> :wq to save and exit.
*If you don't know how to use the text editor, check out this site.
We have learned how to set up a passwordless ssh by using RSA public key generation.
We have also learned how to remove the passwordless login.
If you hit a problem or have feedback (which is highly welcomed) please feel free to get in touch, more details in the footer.