How to set up SSH login on Debian?

To set up SSH login, you need to complete the following steps:

  1. To install the OpenSSH server: Open the terminal and enter the following command to install the OpenSSH server:
sudo apt-get install openssh-server
  1. The ssh server configuration file is located at /etc/ssh/sshd_config.
sudo nano /etc/ssh/sshd_config
  1. You can make the following configuration changes in the configuration file as needed:
  1. If you want to allow the root user to log in via SSH, find and modify the following line:
    #PermitRootLogin prohibit-password

    Change to:
    PermitRootLogin yes

  2. If you want to change the port that the SSH server is listening on, locate and modify the following line:
    #Port 22

    Change it to the port number you wish to use, for example:
    Port 2222

  1. Save and close the configuration file. Next, restart the SSH server for the changes to take effect.
sudo systemctl restart sshd
  1. Set up firewall: If you have a firewall enabled on your Debian system, you need to allow SSH traffic through. If you are using UFW firewall, execute the following command:
sudo ufw allow ssh

If you are using an iptables firewall, please add appropriate rules based on your configuration.

Now, you should be able to log in to your Debian system from another computer using an SSH client.

bannerAds