Skip to main content

Basic SSH Configuration

··2 mins·
Arch-Linux Ssh
Makoto Morinaga
Author
Makoto Morinaga
A personal notebook for tech notes, coding, and system experiments.
Table of Contents

By default, SSH connections allow remote access to the server, but leaving the settings as-is may expose security risks. To mitigate these, we will modify the configuration accordingly.

While SSH settings are generally consistent across Linux distributions, this guide specifically covers configuration on Arch Linux.

Installing OpenSSH
#

On the server, install OpenSSH using the following command:

Terminal
sudo pacman -S openssh

Configuring the SSH Daemon
#

Edit the SSH daemon configuration file at /etc/ssh/sshd_config to enhance security.

Restricting Access to Specific Users
#

To allow SSH access only for specific users, add the following line:

/etc/ssh/sshd_config
AllowUsers <allowed_user>

Disabling Root Login
#

For security reasons, disable SSH login for the root account by modifying the following line:

/etc/ssh/sshd_config
PermitRootLogin no

Changing the SSH Port
#

By default, SSH runs on port 22, which is commonly known and frequently targeted by attackers. Changing this to a random number (e.g., 50134) improves security. Modify the following line:

/etc/ssh/sshd_config
Port 50134

Starting and Enabling the SSH Daemon
#

Start the SSH daemon with:

Terminal
sudo systemctl start sshd.service

To enable SSH to start automatically on boot, run:

Terminal
sudo systemctl enable sshd.service

Verifying SSH Access from the Client
#

From the client PC, connect to the server using:

Terminal
ssh -p 50134 <user>@<server_ip>

Appendix
#

For improved security, consider switching to key-based authentication instead of password authentication. Check out the guide on SSH Key Authentication Setup for details.

Related

How to install Arch Linux
··3 mins
Arch-Linux
Privacy Policy & Disclaimer
·1 min