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.
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).
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.
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.
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.
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.
Portfolio
Recent
Projects
Explore Projects