[Unit] Description=SSH RSA Keygeneration. After=syslog.target Before=sshd.service ConditionPathExists=!/etc/ssh/ssh_host_rsa_key [Service] Type=oneshot EnvironmentFile=/etc/sysconfig/sshd ExecStart=/usr/bin/ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C '' -N '' ExecStartPost=/bin/chown root:ssh_keys /etc/ssh/ssh_host_rsa_key ExecStartPost=/bin/chmod 640 /etc/ssh/ssh_host_rsa_key ExecStartPost=/bin/chmod 644 /etc/ssh/ssh_host_rsa_key.pub ExecStartPost=/sbin/restorecon /ssh/ssh_host_rsa_key /etc/ssh/ssh_host_rsa_key.pub RemainAfterExit=yes [Install] WantedBy=multi-user.target