SSH stands for Secure Shell Service which is used for secure connection between a client computer and a server. Using SSH you can connect to your system remotely, perform administrative tasks and access files. In this tutorial you will learn how to enable SSH on Debian to communicate securely with server.
Before you start with this tutorial, ensure that you’re logged in with non-root user account on your server with sudo privileges.
Install SSH On Debian
By default, SSH server is not installed on Debian system so you need to install it first. It can be easily install from Debian repository by running following commands.
First of all you need to update apt package manager by typing:
sudo apt update
Now issue the below command to install SSH:
sudo apt install openssh-server
It will prompt you to enter password so just enter it and hit Enter key to continue with installation.
SSH service will be started automatically just after finished installation. You can verify installation by issuing below command:
sudo systemctl status ssh
It should show status as active as given below:
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab
Active: active (running) since Mon 2019-04-25 05:08:17 UTC; 45s ago
Main PID: 1001 (sshd)
Tasks: 1 (limit: 1152)
└─1001 /usr/sbin/sshd -D
q key to go back to terminal.
Finally, you installed the SSH on your Debian system and you can connect it via SSH from any remote machine. Linux systems have by default installed SSH client and if you have need to connect it from Windows system you can use PuTTY SSH client.
Connecting to SSH Over LAN
If you want to connect Debian system over LAN then you can use following command:
You need to change the username with your real Debian user name and ip_address with your Debian system ip address which you want to connect.
If you don’t know ip address of your system you can get it by running below command:
Now go back to remote machine from where you were trying to connect and run below command:
When you will connect it for first time, it will prompt you message like below:
The authenticity of host '192.168.43.125 (192.168.43.125)' can't be established.
ECDSA key fingerprint is SHA256:Rcbtm61VXuErBl7nE2+yowF7lgA2bLSiO/33/7qmRJP.
Are you sure you want to continue connecting (yes/no)?
yes and hit Enter key to continue. Next you will be prompted to enter password. Once you provide correct password then you will be logged in and show greeting message as below:
Linux debian 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u2 (2019-05-13) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. ... ...
Connecting to SSH Over Internet
For connect your Debian machine over Internet you must know the public ip address of your machine.
Once you’ve found the IP address you can login by typing:
If you are exposing your machine to the internet you will need to configure the router to accept SSH traffic. Mostly, to configure your router to accept SSH traffic on a non-standard port and forward it to port 22 on the machine running the SSH service.
You can also secure your connection by setting up a SSH key-based authentication to your Ubuntu machine.
Manage SSH Service
For any reason you want to stop SSH service then you can do it by execute below command:
sudo systemctl stop ssh
To start it you can issue below command and can start it:
sudo systemctl start ssh
You can enable SSH service by running following command:
sudo systemctl enable ssh
Again, you can disable the SSH service by issuing below command:
sudo systemctl disable ssh
In this tutorial, you have learned how to install and Enable SSH service on Debian 9 system. You can now login remotely to your server using any SSH client from Linux or Windows system.
If you have any question or suggestion you can leave a comment below.