You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
784 B

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2006-2011 OpenWrt.org
  3. START=50
  4. STOP=50
  5. USE_PROCD=1
  6. PROG=/usr/sbin/sshd
  7. start_service() {
  8. for type in rsa ed25519
  9. do
  10. # check for keys
  11. key=/etc/ssh/ssh_host_${type}_key
  12. [ ! -f $key ] && {
  13. # generate missing keys
  14. [ -x /usr/bin/ssh-keygen ] && {
  15. /usr/bin/ssh-keygen -N '' -t $type -f $key 2>&- >&-
  16. }
  17. }
  18. done
  19. mkdir -m 0700 -p /var/empty
  20. local lport=$(awk '/^Port / { print $2; exit }' /etc/ssh/sshd_config)
  21. [ -z "$lport" ] && lport=22
  22. procd_open_instance
  23. procd_add_mdns "ssh" "tcp" "$lport"
  24. procd_set_param command $PROG -D
  25. procd_close_instance
  26. }
  27. shutdown() {
  28. local pid
  29. stop
  30. # kill active clients
  31. for pid in $(pidof sshd)
  32. do
  33. [ "$pid" = "$$" ] && continue
  34. [ -e "/proc/$pid/stat" ] && kill $pid
  35. done
  36. }