3 # sshd sshd (secure shell daemon)
7 # description: sshd (secure shell daemon) is a server part of the ssh suite. \
8 # Ssh can be used for remote login, remote file copying, TCP port \
9 # forwarding etc. Ssh offers strong encryption and authentication.
12 # Source function library
13 . /etc/rc.d/init.d/functions
16 . /etc/sysconfig/network
18 SERVICE_LIMITS="-u unlimited -Sc 0"
21 [ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd
23 # Check that networking is up.
24 if is_yes "${NETWORKING}"; then
25 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then
26 msg_network_down OpenSSH
34 # See how we were called.
37 # generate new keys with empty passwords if they do not exist
38 if [ ! -f /etc/ssh/ssh_host_key -o ! -s /etc/ssh/ssh_host_key ]; then
39 /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N '' 1>&2
40 chmod 600 /etc/ssh/ssh_host_key
41 [ -x /sbin/restorecon ] && /sbin/restorecon /etc/ssh/ssh_host_key || :
43 if [ ! -f /etc/ssh/ssh_host_rsa_key -o ! -s /etc/ssh/ssh_host_rsa_key ]; then
44 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' 1>&2
45 chmod 600 /etc/ssh/ssh_host_rsa_key
46 [ -x /sbin/restorecon ] && /sbin/restorecon /etc/ssh/ssh_host_rsa_key || :
48 if [ ! -f /etc/ssh/ssh_host_dsa_key -o ! -s /etc/ssh/ssh_host_dsa_key ]; then
49 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' 1>&2
50 chmod 600 /etc/ssh/ssh_host_dsa_key
51 [ -x /sbin/restorecon ] && /sbin/restorecon /etc/ssh/ssh_host_dsa_key || :
54 if [ ! -f /etc/ssh/ssh_host_key ]; then
55 msg_not_running OpenSSH
56 nls "No SSH host key found! You must run \"%s init\" first." "$0"
60 # Check if the service is already running?
61 if [ ! -f /var/lock/subsys/sshd ]; then
65 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sshd
67 msg_already_running OpenSSH
71 if [ -f /var/lock/subsys/sshd ]; then
74 rm -f /var/run/sshd.pid /var/lock/subsys/sshd >/dev/null 2>&1
76 msg_not_running OpenSSH
89 nls "Now the SSH host key will be generated. Please note, that if you"
90 nls "will use password for the key, you will need to type it on each"
92 /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key
93 [ -x /sbin/restorecon ] && /sbin/restorecon /etc/ssh/ssh_host_key || :
94 chmod 600 /etc/ssh/ssh_host_key
95 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
96 [ -x /sbin/restorecon ] && /sbin/restorecon /etc/ssh/ssh_host_rsa_key || :
97 chmod 600 /etc/ssh/ssh_host_rsa_key
98 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
99 chmod 600 /etc/ssh/ssh_host_dsa_key
100 [ -x /sbin/restorecon ] && /sbin/restorecon /etc/ssh/ssh_host_dsa_key || :
104 if [ -f /var/lock/subsys/sshd ]; then
105 msg_reloading OpenSSH
109 msg_not_running OpenSSH >&2
114 msg_usage "$0 {start|stop|init|restart|reload|force-reload|status}"