×


Enable SSH on Debian 9 System - Step by Step procedure ?

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.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related SSH queries on Linux systems.

In this context, we shall look into how to enable SSH on Debian to communicate securely with server. Before proceeding with this procedure, ensure that you're logged in with root user account on your server with sudo privileges.


Steps to 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.

1. Update system apt packages

To begin, First of all you need to update apt package manager by executing:

$ sudo apt update

2. Install SSH

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 2020-04-25 05:08:17 UTC; 45s ago
  Main PID: 1001 (sshd)
     Tasks: 1 (limit: 1152)
    CGroup: /system.slice/ssh.service
            └─1001 /usr/sbin/sshd -D

Finally, Press q key to go back to terminal.

Now, 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.


How to connect to SSH Over LAN ?

If you want to connect Debian system over LAN then you can use following command:

$ ssh username@ip_address

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:

$ ifconfig

Now go back to remote machine from where you were trying to connect and run below command:

$ ssh linuxapt@192.168.43.120

When you will connect it for first time, it will prompt you message like below:

The authenticity of host '192.168.43.120 (192.168.43.120)' can't be established.
ECDSA key fingerprint is SHA256:Rcbtm61VXuErBl7nE2+yowF7lgA2bLSiO/33/7qmRJP.
Are you sure you want to continue connecting (yes/no)?

Type 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.
...
...


How to connect to SSH Over Internet ?

In order to establish connection to 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:

$ ssh username@public_ip_address

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.


How to 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 running below command:

$ sudo systemctl disable ssh


[Need Linux Experts to configure SSH Service on your Linux system? We can help you. ]


Conclusion

This article covers how to install and Enable SSH service on Debian 9 system. In short, SSH stands for Secure Shell. SSH is used for connecting to a remote computer accessing files and perform administrative tasks. You can now login remotely to your server using any SSH client from Linux or Windows system. To increase security of SSH connection by Changing default SSH port to custom one on you system. Get more details about SSH server from official SSH site.


How to Install SSH Server ?

On the system that acts as a server, run the following command:

$ sudo apt install openssh-server

You can check the status of the SSH service with the following command:

$ sudo systemctl status ssh

The system confirms that the SSH service is running.