Linux ubuntu22.04 installation ssh and firewall configuration

install command

Three commands to get it done

sudo apt install ssh -y

sudo ufw allow ssh

sudo ufw reload

process explanation

To install SSH server on Ubuntu 22.04, you can follow these steps:

  1. Open the Terminal application: You can use Ctrl + Alt + Tthe shortcut key to open the Terminal application.

  2. Install the SSH server package: Enter the following command in the terminal aptto install the SSH server package using the package manager.

    sudo apt-get update
    sudo apt-get install openssh-server
    
  3. Start the SSH server: After the installation is complete, the SSH server will start automatically. If you need to start the SSH server manually, you can use the following command:

    sudo systemctl start ssh
    
  4. Configure SSH server: By default, the SSH server is /etc/ssh/sshd_configconfigured using a file. You can use a text editor to modify this file to suit your specific needs. For example, you can change the port number of the SSH server, disable password authentication, enable key authentication, etc.

  5. Firewall Configuration: If you have a firewall enabled on your Ubuntu 22.04 system, you will need to add the SSH server's port to the firewall's allow list to ensure that you can connect to the SSH server from other computers. You can use the following command to open the SSH server port (the default port is 22):

    sudo ufw allow ssh
    

    If you are using a custom port number, you can open it with:

    sudo ufw allow [port_number]/tcp
    

    Then, reload the firewall configuration with the following command:

    sudo ufw reload
    

Now that you have successfully installed and configured your SSH server, you can use an SSH client from another computer to connect to and manage your Ubuntu 22.04 system remotely.

Guess you like

Origin blog.csdn.net/a772304419/article/details/132105390