0
0
mirror of https://github.com/openwrt/packages.git synced 2025-02-12 02:21:14 +00:00
packages/net/openssh/files/sshd.failsafe
Rucke Teg fb113c5a70 openssh-server: change sshd.failsafe
There is no need to remove root password from /etc/shadow as the
password in the file is blank anyway in the failsafe mode.

Signed-off-by: Rucke Teg <rucketeg@protonmail.com>
2022-02-10 21:10:08 -08:00

29 lines
547 B
Bash
Executable File

#!/bin/sh
failsafe_sshd () {
# if dropbear is executable it can handle failsafe
[ -x /usr/sbin/dropbear ] && return
sshd_tmpdir=/tmp/sshd
mkdir $sshd_tmpdir
for type in ed25519; do
key=$sshd_tmpdir/ssh_host_${type}_key
ssh-keygen -N '' -t ${type} -f ${key}
done
mkdir -m 0700 -p /var/empty
cat > $sshd_tmpdir/sshd_config <<EOF
HostKey $sshd_tmpdir/ssh_host_ed25519_key
PermitRootLogin yes
PermitEmptyPasswords yes
EOF
/usr/sbin/sshd -f $sshd_tmpdir/sshd_config -E $sshd_tmpdir/sshd.log
}
boot_hook_add failsafe failsafe_sshd