Introduction
In system administration, knowing when to restart services and when to modify their configuration files is a crucial skill. This article focuses on the SSH daemon (SSHd) and discusses the differences between restarting the SSHd service and making configuration changes.
What is SSHd?
OpenSSH is a popular open-source suite of tools used for securely accessing remote servers. The SSH daemon (SSHd) is the service responsible for handling incoming SSH connections. It listens on the standard SSH port (22) and manages authentication, encryption, and other security features.
Restarting the SSHd Service
Restarting the SSHd service is typically required when there is a misconfiguration, a security vulnerability, or when applying system updates that affect the SSHd service. To restart the SSHd service, use the following command:
sudo systemctl restart sshd
Making Configuration Changes
Configuration changes to the SSHd service are usually made by editing the /etc/ssh/sshd_config file. This file contains various options that control the behavior of the SSHd service. Some common configuration changes include:
- Changing the SSH port number
- Setting up public key authentication
- Allowing or denying access based on IP addresses
Differences Between Restarting and Making Config Changes
Restarting the SSHd service and making configuration changes serve different purposes:
Restarting Affects Current Connections
When you restart the SSHd service, all current connections are terminated, and new connections are established based on the new configuration. This can be useful when implementing a security update or when troubleshooting connection issues.
Config Changes Persist
Configuration changes made to the /etc/ssh/sshd_config file persist across service restarts. This means that once you make a change, it will be applied to all new connections, without the need to restart the service.
Summary
In summary, restarting the SSHd service is used to apply changes that require an immediate effect, such as security updates or troubleshooting. Making configuration changes to the /etc/ssh/sshd_config file is used to modify the behavior of the SSHd service in a persistent manner.
References
DigitalOcean: How to Securely Access Your Droplet via SSH