Linux Administration Cookbook
上QQ阅读APP看书,第一时间看更新

How it works...

Now that we've been through and changed a few common settings, we're going to have a quick look at what happens when you restart the SSH daemon.

SSH's systemd unit file will look similar to this, though your system may vary:

[vagrant@centos2 ~]$ cat /etc/systemd/system/multi-user.target.wants/sshd.service 
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.service
Wants=sshd-keygen.service

[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/sshd
ExecStart=/usr/sbin/sshd -D $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

By default, we can see that the binary used is /usr/sbin/sshd with $OPTIONS passed from elsewhere (in this case the EnvironmentFile value, as listed previously).

Reading the manual for sshd, we find the following section:

The -f config_file option (https://man.openbsd.org/sshd) is described as follows:

"Specifies the name of the configuration file. The default is /etc/ssh/sshd_config. sshd refuses to start if there is no configuration file."

Here, we have the answer of why sshd_config is read by default—it's baked in.