Install SSH on Debian: A Complete Guide
To install the SSH service on Debian, you can follow these steps:
- Open the terminal and log into the system as the root user or a user with sudo privileges.
- Run the following command to update the system software package list:
- Please update the apt package manager.
- Install the OpenSSH server software package.
- Please install openssh-server using the sudo apt command.
- During the installation process, you may be prompted to enter confirmation to continue the installation. Enter “Y” and press the Enter key.
- After the installation is complete, the SSH service will start automatically. You can check the status of the SSH service using the following command.
- Check the status of the ssh service by using the command: sudo systemctl status ssh
- If the SSH service is running, you will see an output line similar to “Active: active (running)”.
- By default, the SSH service will authenticate all users in the system. If you want to restrict SSH access to specific users only, edit the SSH server configuration file.
- open the sshd_config file located in /etc/ssh using the nano editor with superuser privileges
- In the opened file, locate the line “#PermitRootLogin prohibit-password” and change it to “PermitRootLogin no”. This will disable root user login via SSH.
- If you want to allow specific users to log in via SSH, add the following line:
- Grant access to specific users by using their usernames.
- Replace “username” with the username(s) you wish to allow for login. If there are multiple users, separate them with a space.
- Save the file and exit the editor.
- Reload the SSH server configuration to apply the changes.
- Reboot the ssh service using systemctl.
You have now successfully installed and configured the SSH service. You can now use an SSH client to connect to the Debian system.