Restart Sshd
Managing services is a key responsibility for sysadmins. There is no doubt that the transition between the older SysV method (using the service
and chkconfig
commands) and the newer systemd
-based commands (such as systemctl
) was controversial. In fact, many sysadmins still have very strong feelings one way or the other.
Restart Sshd Ubuntu
The reality is that many distributions, Red Hat Enterprise Linux (RHEL) included, have begun managing services with systemd
. Hence, you and I need to know how to work with the systemctl
management command.
More Linux resources
Restart Sshd_config
OpenSSH for OpenBSD. Since OpenSSH is developed by the OpenBSD group, OpenSSH is included in the base operating system, starting at OpenBSD release 2.6. Should show: - Active: active (running) If it's running there's no need to restart it. If you still want to restart it, Ubuntu calls the service ssh, not sshd. Service ssh restart But if its not Ubuntu Desktop, using CLI: sudo systemctl restart ssh sudo service ssh restart The service is also controlled by upstart, and not sysvinit. You can either use the command “service sshd restart” OR “/etc/init.d/sshd restart” to restart SSH service. There is no need to run both commands. root@server # service sshd restart Stopping sshd: OK. Sudo stop ssh sudo start ssh As it leverages upstart, this is The Best Way™ to do it, rather than using /etc/init.d/ssh, service, or invoking sshd directly. Make sure to run both commands; if you get an error on stop ssh, start ssh anyway and see what it says—the service could already be stopped.
Restart Sshd Daemon
I'm not the kind of author/trainer/admin that assumes everyone is advanced. With that in mind, I'm going to aim this article at the folks who need a fundamental and straightforward explanation of how and when to use the more common systemctl
subcommands. At the end, I also provide a great trick for quickly displaying all the systemctl
subcommands.
Note: The systemctl man page refers to the second word in the string as a 'command,' which seems somewhat confusing. I will refer to systemctl
itself as a command, then the string following it as a subcommand. The argument is the name of the service and occupies the third position in the syntax.
Here is a syntax example:
I'll demonstrate how and when to use systemctl
. Most of my examples use the common sshd
service.
[ Readers also enjoyed: How I learned to stop worrying and love systemd ]
Service status
The best place to start is to understand the current functionality of the service. I'll begin with the most simple approach, the use of the status
subcommand: