Mastering VM Management: From SSH Key Setup to Cockpit Connection.

Mastering VM Management: From SSH Key Setup to Cockpit Connection.

ยท

2 min read

Changing the SSH Port for Security

Changing the default SSH port from 22 to another port can help reduce the risk of automated attacks. Here are the steps to change the SSH port number and connect to Cockpit for managing your server.

This is the previous post on to create vm,and connect to mobaxterm;https://chidinmautilitarian.hashnode.dev/continuing-with-ssh-keys-creating-a-vm-users-and-groups-using-mobaxterm

Step 1: Create a user and give the user admin role.

Commands: (adduser grace).input necessary information about the user.

command: (visudo) to give admin role to the user.Go under the root and input all information needed

ctrl x & y,then enter.

Step 2: Update the Database & Packages.

Command: (sudo apt update)

Change the Port Number:

  • Find the line that says #Port 22 and change it to another port number.

  • Command: (cd /etc/ssh/

    ll

    nano sshd_config)

    To check if its running

  • systemctl restart ssh

  • systemctl status ssh

    Go back to the VM created and create a firewall rule,accepting port 1866.

    Install Cockpit:

    • If Cockpit is not already installed on your VM, you can install it using the following commands:(sudo apt install cockpit -y)

    • Start and Enable Cockpit:

      • Start the Cockpit service and enable it to start on boot:

        systemctl start cockpit

        systemctl status cockpit)

        Update Firewall Rules

        1. Allow Cockpit Port Number

          Access Cockpit Web Interface:

          • Open a web browser and go to https://<your-vm-ip>:9090.

          • Log in using your VM's username and password or SSH key

          • We will be using the user created and password.

            By following these steps, you can enhance the security of your SSH access by changing the default port and leverage Cockpit for an easy-to-use web interface to manage your server. If you have any questions or need further assistance, feel free to ask!

ย