OpenSUSE MicroOS - Adding A User

Short step by step on creating a user to administer your server without the root user. We will create a new limited user who can use sudo when needed.

OpenSUSE MicroOS - Adding A User
OpenSUSE Logo and Text

Managing your server via SSH and Cockpit etc is important but you will not want to do this with the root user. Infact logging in remotely with root via SSH etc is disabled by default.

So how do you administrate your server removely without root access?

Creating a new user that has access and is also part of the admin groups of the server (so you can elevate privledges when needed) is a safer way to do this. This simple guide will take you through those steps.

  1. Create a New User: You can create a new user with the useradd command. Replace newuser with the username you want to create:
sudo useradd -m newuser

The m flag creates a home directory for that user also, helpful for handling files etc as the user wont have access to other parts of the system via normal use.

  1. Set Password for the New User: Set a password for the newly created user:
sudo passwd newuser
  1. Grant sudo Privileges: If you want the user to have sudo privileges, add them to the root group:
sudo usermod -aG root newuser
  1. Restart Services: To ensure changes persuĂ­st and you can test them out, it can be a great idea to restart the needed services:
sudo systemctl restart sshd
sudo systemctl restart cockpit

This will restart the SSH service and the Cockpit service.

Now you should be able to login with the new user to Cockpit and SSH. Remember the user will login with normal user rights, if you need to use sudo then you can elevate the command by typing sudo before the command or login as root user rights by typing su and logging in with the root password.

Please consider supporting my content by subscribing to me here, allowing me to provide easy to follow, step by step tutorials and information for beginners and students of Programming, Networking and IT.