How to Set Up SSH Server in Linux

Installation

First you must check if you have the ssh server installed on your system.

Debian/Ubuntu:

sudo apt install openssh-server

Arch:

sudo pacman -S openssh

A message will appear if it is already installed, otherwise accept the prompts and download the package.


Setup

The ssh server service must be enabled.

sudo systemctl start sshd.service

The service is now running on the system.

The status of the service can be checked with the same command.

sudo systemctl status sshd.service

The port being used can be found with this command.


Configuration

The configuration settings are stored in a file located in /etc/ssh/sshd_config. This file can be edited with root access to edit the settings.

To change the port number:

Port 10100

To set the file for authorized keys:

AuthorizedKeysFile .ssh/keys_file

To deny clear text passwords:

PasswordAuthentication no

All of these settings are already present in the file, they just need to be uncommented and changed.

After performing any changes to this file, the ssh service must be restarted:

sudo systemctl restart sshd.service