Software Development

Creating an OS User on Ubuntu: A Step-by-Step Guide

Blog bannerBlog banner

In the realm of server administration, creating a dedicated Operating System (OS) user is a fundamental step to enhance security and streamline various processes. In this article, we will guide you through the process of creating an OS user on an Ubuntu 22.04 server.

Step 1: Generate an RSA Key Pair Locally

Start by generating an RSA key pair on your local machine. Open your terminal and run the following command. 

Replace my-key with any name you would like. 

When prompted for a passphrase, leave it blank for simplicity in this example. This command creates two files: my-key (private key) and my-key.pub (public key).

Step 2: Login to Your Server and Create the OS User

Now, it's time to log in to your Ubuntu 22.04 server. Replace <your-username> with your desired username.

Follow the prompts to provide any additional information you wish to associate with the new user. This command creates a new user with the specified home directory and bash as the default shell.

Step 3: Configure the User with the Generated Key Pair

Switch to the newly created user and configure it to use the RSA key pair generated in Step 1.

These commands switch to the new user, create the necessary directory structure, and configure the authorized keys file for secure SSH authentication.

Step 4: Optional - Granting sudo Access

If you require administrative privileges, you can grant sudo access to the newly created user. Exercise caution and provide only the necessary permissions.

This command adds the user to the sudoers file, allowing them to execute commands with elevated privileges.

Step 5: SSH into the Server as the New User

To demonstrate the user's ability to SSH into the server, use the following command:

Replace <path-to-my-key> to the path of the private key of the key pair created in Step 1. Replace <your-username> with the username you chose in Step 2. Replace <your-server-ip> with the actual IP address or hostname of your server. You should now be logged into the server as the newly created user, leveraging the security of SSH key authentication.

Congratulations! You have successfully created an OS user on your Ubuntu 22.04 server, and the user is now capable of securely SSH-ing into the server using the generated key pair. 

card user img
Twitter iconLinked icon

Zignuts Technolab delivers future-ready tech solutions and keeps you updated with the latest innovations through our blogs. Read, learn, and share!

Say Hello

We’re just a message away from making great things happen.

Valid number
Submit
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
download ready
Thank You
Your submission has been received.
We will be in touch and contact you soon!

Our Latest Blogs

Load More

Our Latest Blogs

View All Blogs