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.

30 lines
602 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. sed -i 's/^root:.*/root::0:17000:::::/g' /etc/shadow
  8. for type in ed25519; do
  9. key=$sshd_tmpdir/ssh_host_${type}_key
  10. ssh-keygen -N '' -t ${type} -f ${key}
  11. done
  12. mkdir -m 0700 -p /var/empty
  13. cat > $sshd_tmpdir/sshd_config <<EOF
  14. HostKey $sshd_tmpdir/ssh_host_ed25519_key
  15. PermitRootLogin yes
  16. PermitEmptyPasswords yes
  17. EOF
  18. /usr/sbin/sshd -f $sshd_tmpdir/sshd_config -E $sshd_tmpdir/sshd.log
  19. }
  20. boot_hook_add failsafe failsafe_sshd