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.

Adding 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)
You can check if you did it right by running cat /etc/sudoers.d/<username> and checking that the content matches as above.

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