Create new user, to use a public key
- create a new user
- give that user sudo privileges
- test that the new user can use sudo privileges.
- test that the new user can connect through SSH.
create a new user
sudo useradd fred
and set password:
sudo passwd fred
tip - You can list all users by looking in the file
give that user sudo privileges
Add a user to the sudo group with:
gpasswd -a fred sudo
(here's another way...
usermod -aG sudo fred ...?)
You must be root or have sudo privileges in order to do this.
test that the new user can use sudo privileges
su (switch user) to switch to the new user...
su - fred
(you will need to use their password to do this)
Try and do this... (it shouldn't let you...)
ls -la /root
Now sudo do it!
sudo ls -la /root
(and enter fred's password...)
test that the new user can connect through SSH