Continuing with SSH Keys: Creating a VM, Users, and Groups Using MobaXterm

Continuing with SSH Keys: Creating a VM, Users, and Groups Using MobaXterm

In the last post, we discussed how to create an SSH key. Now, let's take it a step further by using that SSH key to create a virtual machine (VM), configure it with the public key, and use MobaXterm to connect with the private key. We'll also cover creating users and groups on the VM using MobaXterm.

Step 1: Create a Virtual Machine (VM)

  1. Sign In: Log in to your cloud provider’s portal

  2. Create VM:

    • Navigate to the VM creation section.

    • Choose the necessary configurations (name, region, size, etc.).

    • In the SSH key section, upload your public key (id_rsa.pub).which is saved in the folder we created before.

    • Complete the setup and create the VM.

Step 2: Connect to Your VM Using MobaXterm

  1. Open MobaXterm: Launch MobaXterm on your local machine.

  2. New SSH Session:

    • Click the Session icon and select SSH.

    • Enter your VM’s public IP address or hostname.

    • Choose Specify username, enter the username you configured for your VM.

    • Under the Advanced SSH settings, check Use private key and browse to select your private key file (id_rsa).

  3. Connect: Click OK to connect to your VM. If your private key is configured correctly, you should be connected to your VM without being prompted for a password.

    Step 3: Create Users and Groups on the VM

    1. Create a New User:

      • Once connected to the VM, open a terminal window in MobaXterm.

      • Use the following command to create a new user:

        (sudo adduser joshua)

      • click on enter,and input all neccessary information about the user.

To check where all users are type this command “cat /etc/passwd”

Create a New Group:

  • Create a new group using the command:

  • sudo groupadd (newgroup)

  • To check if the group has been added successfully

  • sudo cat /etc/group

Add User to Group:

  • Add the new user to the new group

  • sudo usermod -aG (newgroup newusername)

To check if the user was added succesfully,use this command:

cat /etc/group

To add user to two or more group,use this command:

sudo usermod -aG (groupname,groupname,username)

By following these steps, you can securely connect to your VM using SSH keys and MobaXterm, and manage users and groups efficiently. This setup not only enhances security but also streamlines access management for your VM.

I hope this detailed guide helps! If you have any questions or need further clarification, feel free to reach out.