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
19 [ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd
21 # Check that networking is up.
22 if is_yes "${NETWORKING}"; then
23 if [ ! -f /var/lock/subsys/network ]; then
24 msg_network_down OpenSSH
32 # See how we were called.
35 # generate new keys with empty passwords if they do not exist
36 if [ ! -f /etc/ssh/ssh_host_key -o ! -s /etc/ssh/ssh_host_key ]; then
37 /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N '' 1>&2
38 chmod 600 /etc/ssh/ssh_host_key
40 if [ ! -f /etc/ssh/ssh_host_rsa_key -o ! -s /etc/ssh/ssh_host_rsa_key ]; then
41 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' 1>&2
42 chmod 600 /etc/ssh/ssh_host_rsa_key
44 if [ ! -f /etc/ssh/ssh_host_dsa_key -o ! -s /etc/ssh/ssh_host_dsa_key ]; then
45 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' 1>&2
46 chmod 600 /etc/ssh/ssh_host_dsa_key
49 if [ ! -f /etc/ssh/ssh_host_key ]; then
50 msg_not_running OpenSSH
51 nls "No SSH host key found! You must run \"%s init\" first." "$0"
55 # Check if the service is already running?
56 if [ ! -f /var/lock/subsys/sshd ]; then
61 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sshd
63 msg_already_running OpenSSH
67 if [ -f /var/lock/subsys/sshd ]; then
70 rm -f /var/run/sshd.pid /var/lock/subsys/sshd >/dev/null 2>&1
72 msg_not_running OpenSSH
85 echo "Now the SSH host key will be generated. Please note, that if you"
86 echo "will use password for the key, you will need to type it on each"
88 /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key
89 chmod 600 /etc/ssh/ssh_host_key
90 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
91 chmod 600 /etc/ssh/ssh_host_rsa_key
92 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
93 chmod 600 /etc/ssh/ssh_host_dsa_key
101 msg_usage "$0 {start|stop|init|restart|reload|status}"