1

I would like to know what are the ways to automatically start daemons (sshd) in Fedora system. I know I can write a startup script that will put on /etc/init.d/.

What are the other options?

Somewhere I read that now in the new version of this can be done using the commands in the terminal, but I do not remember what it was.

My 2 question. I install ssh from source. When keys are generated for a server? During the installation?

  • chkconfig perhaps? Also, I assume you mean sshd, not ssh? ssh-keygen to generate your own keys (not server keys) – barrycarter Nov 3 '14 at 18:35
  • I also read about systemctl. Yes, I mean sshd. I mean if the server - daemon to work properly are automatically generated keys? The lecturer has mentioned. – lukassz Nov 3 '14 at 18:45
  • Yes, installing sshd should install the public and private server keys. On my machine, it's systemsettings on the off chance that helps anyone – barrycarter Nov 3 '14 at 19:46
  • Do not write a shell script and put it in /etc/init.d/. Also, you don't need chkconfig. Those things are used on SysV init based systems. However, Fedora (like many other popular distributions nowadays) is based on sytemd. systemd does not need a shell script for every service, instead it uses service unit files. Those contain the same information regarding what is started and how but without the shell code around it (which was usually mostly identical in most scripts anyway). – basic6 Nov 14 '15 at 15:15
1

In Fedora 20, there's a directory

/etc/systemd/system/multi-user.target.wants

I didn't compile from source. Unless I'm mistaken these are the files/links which enable the commands below.

The file is a link to

sshd.service -> /usr/lib/systemd/system/sshd.service

Here's an example of the default sshd file.

[Unit]
Description=OpenSSH server daemon
After=syslog.target network.target auditd.service

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

[Install]
WantedBy=multi-user.target

If you have the symbolic link in the location above, pointing to a file that contains the configuration above you'll be able to use the systemctl commands below.

Assuming you're using a version of Fedora 15 or later...

systemctl start sshd
systemctl enable sshd

The first command will start, the second command will enable auto-starting at boot.

systemctl restart sshd 

Will restart the service.

Also see

systemctl status sshd

The same series of systemctl commands work for various services. To see a list of running services...

systemctl list-units --type service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.