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.

28 lines
547 B

  1. #!/bin/sh
  2. failsafe_sshd () {
  3. # if dropbear is executable it can handle failsafe
  4. [ -x /usr/sbin/dropbear ] && return
  5. sshd_tmpdir=/tmp/sshd
  6. mkdir $sshd_tmpdir
  7. for type in ed25519; do
  8. key=$sshd_tmpdir/ssh_host_${type}_key
  9. ssh-keygen -N '' -t ${type} -f ${key}
  10. done
  11. mkdir -m 0700 -p /var/empty
  12. cat > $sshd_tmpdir/sshd_config <<EOF
  13. HostKey $sshd_tmpdir/ssh_host_ed25519_key
  14. PermitRootLogin yes
  15. PermitEmptyPasswords yes
  16. EOF
  17. /usr/sbin/sshd -f $sshd_tmpdir/sshd_config -E $sshd_tmpdir/sshd.log
  18. }
  19. boot_hook_add failsafe failsafe_sshd