Linux: Installing SSH Server
Prerequisites
1. The device must be running a Linux-based operating system.
2. A Linux terminal must be available on the system.
Checking for OpenSSH
Most Linux distributions come with the OpenSSH server by default, so it is recommended to check if it is already installed before proceeding with installation.
To check for the presence and version of the installed OpenSSH Server in your system, use the command:
sshd -V
This command key does not exist, but entering a non-existent key is the simplest and most universal way to find out the version of the OpenSSH server.
If the result of the sshd -V command displays information about the version of the OpenSSH server and the release date, as in the example below, then the installation of the OpenSSH server is not required:
root@66602acb695d3:~# sshd -V unknown option -- V OpenSSH_8.2p1 Ubuntu-4ubuntu0.11, OpenSSL 1.1.1f 31 Mar 2020 usage: sshd [-46DdeiqTt] [-C connection_spec] [-c host_cert_file] [-E log_file] [-f config_file] [-g login_grace_time] [-h host_key_file] [-o option] [-p port] [-u len] root@66602acb695d3:~#
The OpenSSH server is not present on the system if the execution of the command results in an error about the command not being found, for example:
sshd -V bash: sshd: command not found
If your system does not have the OpenSSH server installed, you can install it using the package manager of your distribution, as described in the further instructions.
Installing OpenSSH
Before installing the OpenSSH server, it is recommended to update your system's package list using a command, for example, sudo apt update or sudo dnf update. This is an important, but not mandatory step, that helps ensure you receive the latest available versions of packages. The exception is Arch Linux, where both update and installation are performed with a single command sudo pacman -Syu, which includes the -Syu key for updating.
Select commands according to the version and type of your operating system to ensure the correct installation of the OpenSSH server.
Ubuntu / Debian / Linux Mint:
sudo apt update sudo apt install openssh-server
Fedora 22 and newer:
sudo dnf update sudo dnf install openssh-server
Fedora 21 and older:
sudo yum update sudo yum install openssh-server
Arch Linux:
sudo pacman -Syu openssh
In Arch Linux, the openssh package includes both client and server components.
OpenSUSE:
zypper up sudo zypper install openssh
Also in OpenSUSE, the openssh package includes both a client and a server.
CentOS/RHEL 8 and newer:
sudo dnf update sudo dnf install openssh-server
CentOS/RHEL 7 and older:
sudo yum update sudo yum -y install openssh-server
After installing the OpenSSH server, you can proceed to create a new user to connect to the server. For instructions on how to create a user in Linux, see "Linux: Creating New User".
If you prefer to connect as the root user, you may skip directly to installing the client from which you will manage the server. The OpenSSH client installation process is described in the section "Installing OpenSSH Client".