comparison network/openssh/sshd @ 121:f2c94d482098

network/openssh: initial import, closes #1156
author David Demelier <markand@malikania.fr>
date Sun, 10 Mar 2019 11:49:40 +0100
parents
children 9f90de3d806f
comparison
equal deleted inserted replaced
120:5259bdf60de7 121:f2c94d482098
1 #!/bin/sh
2 #
3 # /etc/rc.d/sshd: run control script for sshd
4
5 if [ -f /etc/rc.conf ]; then
6 source /etc/rc.conf
7 fi
8
9 : ${SSHD_CMD:=/usr/sbin/sshd}
10 : ${SSHD_ARGS:=}
11 : ${SSHD_PID:=/var/run/sshd.pid}
12
13 sshd_start()
14 {
15 if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
16 /usr/bin/ssh-keygen -q -t rsa -b 2048 -N "" -f /etc/ssh/ssh_host_rsa_key
17 fi
18 if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
19 /usr/bin/ssh-keygen -q -t dsa -N "" -f /etc/ssh/ssh_host_dsa_key
20 fi
21 if [ ! -f /etc/ssh/ssh_host_ecdsa_key ]; then
22 /usr/bin/ssh-keygen -q -t ecdsa -b 521 -N "" -f /etc/ssh/ssh_host_ecdsa_key
23 fi
24 if [ ! -f /etc/ssh/ssh_host_ed25519_key ]; then
25 /usr/bin/ssh-keygen -q -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key
26 fi
27
28 echo "Starting sshd: $SSHD_CMD $SSHD_ARGS"
29 $SSHD_CMD $SSHD_ARGS -p $SSHD_PID
30 }
31
32 sshd_status()
33 {
34 if [ -s $SSHD_PID ]; then
35 echo "sshd is running with pid: `cat $SSHD_PID`"
36 else
37 echo "sshd is not running"
38 fi
39 }
40
41 sshd_stop()
42 {
43 if [ -s $SSHD_PID ]; then
44 echo "Stopping sshd..."
45 kill -QUIT $SSHD_PID
46 fi
47 }
48
49 sshd_restart()
50 {
51 sshd_stop
52 sleep 3
53 sshd_start
54 }
55
56 case $1 in
57 start)
58 sshd_start
59 ;;
60 status)
61 sshd_status
62 ;;
63 stop)
64 sshd_stop
65 ;;
66 restart)
67 sshd_restart
68 ;;
69 *)
70 echo "usage: $(basename $0) restart|start|status|stop"
71 ;;
72 esac