...
Create or open the
/home/username/.ssh/authorized_keys
file.Code Block sudo nano /home/username/.ssh/authorized_keys
Copy and append the text of the public key file into the
authorized_keys
file.Set the rights to this file to 600 (owner read and write only).
Code Block sudo chmod 600 /home/username/.ssh/authorized_keys sudo chown username:username /home/username/.ssh/authorized_keyss
Remove requirement for password
By default the user will still be prompted for a password when attempting to use sudo
. To remove this requirement, use visudo
.
Run
visudo
.Code Block sudo visudo
Find the sudo group entry. It will look like the following:
Code Block %sudo ALL=(ALL:ALL) ALL
Add a no-password rule:
Code Block your_username ALL=(ALL) NOPASSWD:ALL
If you wish to remove the sudo password requirement for all users:
Code Block %sudo ALL=(ALL:ALL) NOPASSWD:ALL