Skip to main content

Step 1: Create a user

If you logged in as root (which you probably did), you're gonna need to create a user. Logging in as root is very dangerous, even more when login via password is enabled. Hackers could get access to your machine and do literally anything with it, since they would also be root.

Creating a user

To create a new user, you can use: adduser <username>.
This tool is going to ask a bunch of questions, answer them as you see fit. Please choose a very strong password.

Set password

Now we are going to set a password for that user, run passwd <username>. It should prompt for a password and for a confirmation.

Add user to sudoers

After that, we're going to allow this user to run commands as root.
Try running: sudo visudo -f /etc/sudoers.d/<username>.
This should open a text editor, add this to the file:

<username>   ALL=(ALL:ALL) ALL

This will allow your user to run commands as root, with your password.

If the text editor looks and/or feels weird (text not pasting, unable to write, ...), you landed in vim, a very weird place (I use it daily). To paste the text, you can press Escape and then p, probably. If that doesn't work then press Escape, then i, then Ctrl+Shift+V. Then press Escape, and type :wq.

If at this point you're in the terminal and not editing a file, you probably did everything right! (ADD SCREEN/VIDEO)


NowYou wecan arecheck goingif toyou setdid ait passwordright forby that user, runrunning passwdcat /etc/sudoers.d/<username>. It should prompt for a password and forchecking athat confirmation.
the content matches as above.

After that, you can try to logout, and login as that user: ssh <username>@<hostname>.