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

Published on October 9, 2023

Zignuts Technolab

how to create an os user on ubuntu?
Software Development

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. 

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

linkedin-blog-share-iconfacebook-blog-share-icontwitter-blog-icon

Portfolio

Recent

explore-projects

Testimonials

Why they’re fond of us?

tm img

A reliable and flexible technical partner, Zignuts Technolab enables a scalable development process. The team offers a comprehensive array of expertise and scalability that yields an optimized ROI. Direct contact with specialists maintains a seamless workflow and clear communication.

Joeri

Technical Architect
Blockchain-based Real Estate Platform Company, Belgium

Zignuts Technolab transformed our platform by simplifying code, redesigning key aspects, and adding new features, all within impressive timelines. Their project management and communication were exceptional.

Ali

Managing Director
Automobile Company, UAE

Zignuts team has been instrumental in our platform’s development including backend, frontend and mobile apps, delivering excellent functionality and improving speed over time. Their project management, pricing and communication are top-notch.

Shoomon

Co-Founder
AI-Based Fintech Startup, UK

Zignuts has delivered excellent quality in developing our website and mobile apps. Their genuine interest in our business and proactive approach have been impressive.

Jacob

Technical Architect
Blockchain-based Real Estate Platform Company, Belgium

Their team's dedication and knowledge in handling our relocation information platform made the collaboration seamless and productive. Highly recommend their services.

Stephen

CEO & Founder
Social Community Platform, Germany

Zignuts Technolab provided highly skilled full-stack developers who efficiently handled complex tasks, from backend development to payment gateway integration. Their responsiveness and quality of work were outstanding.

Houssam

Chief Product Officer
Enterprise Solutions, Jordan

Zignuts Technolab has been highly efficient and responsive in developing our rewards and wellness app. Their ability to integrate feedback quickly and their solid expertise make them a great partner.

Namor

Developer
Wellness Startup, Thailand