6

Create a Sudo User on Debian

 2 years ago
source link: https://www.vultr.com/docs/create-a-sudo-user-on-debian-best-practices
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
<?xml encoding="utf-8" ??>

Introduction

Performing server administration as a non-root user is a best practice for security. After launching your Vultr VPS, your first task as root should be to set up a non-root user with sudo access.

This guide applies to the following versions:

  • Debian 9 "Stretch"
  • Debian 10 "Buster"
  • Debian 11 "Bullseye"

1. Install sudo

Some Debian installations do not come with sudo installed. If your does not, install sudo with apt.

# apt install sudo

2. Add a New User Account

Create a new user account with the adduser command. Use a strong password for the new user. You can enter values for the user information, or press ENTER to leave those fields blank.

# adduser example_user
Adding user `example_user' ...
Adding new group `example_user' (1001) ...
Adding new user `example_user' (1001) with group `example_user' ...
Creating home directory `/home/example_user' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for example_user
Enter the new value, or press ENTER for the default
        Full Name []: Example User
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y

3. Add the User to the Sudo Group

Add the new user to the sudo group.

# adduser example_user sudo

4. Test

Switch to the new user.

# su - example_user

Verify you are the new user with whoami, then test sudo access with sudo whoami, which should return root.

$ whoami
example_user
$ sudo whoami
[sudo] password for example_user:
root

Conclusion

The new user account is ready to use. As a best practice, use this sudo user for server administration. You should avoid using root for maintenance tasks.

Want to contribute?

You could earn up to $600 by adding new articles


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK