mirror of
https://github.com/dguglielmi/sunny-overlay.git
synced 2025-12-06 11:42:40 +01:00
sys-kernel/dracut-openssh: add ebuild
This commit is contained in:
10
sys-kernel/dracut-openssh/files/dracut-openssh.conf
Normal file
10
sys-kernel/dracut-openssh/files/dracut-openssh.conf
Normal file
@@ -0,0 +1,10 @@
|
||||
# Dracut OpenSSH configuration
|
||||
#
|
||||
#SSHD_OPTS="-e -p 22"
|
||||
#
|
||||
#AUTHORIZED_KEYS="/root/.ssh/authorized_keys"
|
||||
#
|
||||
#DSA_HOST_KEY="/etc/ssh/ssh_host_dsa_key"
|
||||
#ECDSA_HOST_KEY="/etc/ssh/ssh_host_ecdsa_key"
|
||||
#ED25519_HOST_KEY="/etc/ssh/ssh_host_ed25519_key"
|
||||
#RSA_HOST_KEY="/etc/ssh/ssh_host_rsa_key"
|
||||
61
sys-kernel/dracut-openssh/files/module-setup.sh
Normal file
61
sys-kernel/dracut-openssh/files/module-setup.sh
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
# called by dracut
|
||||
check() {
|
||||
#check for sshd
|
||||
require_binaries sshd || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
depends() {
|
||||
echo network
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
[ -z ${AUTHORIZED_KEYS} ] && AUTHORIZED_KEYS="/root/.ssh/authorized_keys"
|
||||
[ -z ${SSHD_OPTS} ] && SSHD_OPTS="-e -p 22"
|
||||
[ -z ${DSA_HOST_KEY} ] && DSA_HOST_KEY="/etc/ssh/ssh_host_dsa_key"
|
||||
[ -z ${ECDSA_HOST_KEY} ] && ECDSA_HOST_KEY="/etc/ssh/ssh_host_ecdsa_key"
|
||||
[ -z ${ED25519_HOST_KEY} ] && ED25519_HOST_KEY="/etc/ssh/ssh_host_ed25519_key"
|
||||
[ -z ${RSA_HOST_KEY} ] && RSA_HOST_KEY="/etc/ssh/ssh_host_rsa_key"
|
||||
|
||||
local keytype keyfile
|
||||
for keytype in dsa ecdsa ed25519 rsa; do
|
||||
case ${keytype} in
|
||||
dsa) keyfile=${DSA_HOST_KEY} ;;
|
||||
ecdsa) keyfile=${ECDSA_HOST_KEY} ;;
|
||||
ed25519) keyfile=${ED25519_HOST_KEY} ;;
|
||||
rsa) keyfile=${RSA_HOST_KEY} ;;
|
||||
esac
|
||||
|
||||
[ -f ${keyfile} ] && inst_simple "${keyfile}" /etc/ssh/ssh_host_${keytype}_key
|
||||
done
|
||||
|
||||
inst_simple "${moddir}/sshd_config" /etc/ssh/sshd_config
|
||||
inst_simple "$(which sshd)"
|
||||
|
||||
inst_simple "${moddir}/sshd.service" ${systemdsystemunitdir}/sshd.service
|
||||
mkdir -p "${initdir}/etc/sysconfig"
|
||||
echo "SSHD_OPTS=\"${SSHD_OPTS}\"" > "${initdir}/etc/sysconfig/sshd"
|
||||
|
||||
if [ -f ${AUTHORIZED_KEYS} ]; then
|
||||
inst_simple ${AUTHORIZED_KEYS} /root/.ssh/authorized_keys
|
||||
else
|
||||
dfatal "No authorized_keys for root user found!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
getent passwd sshd >> "${initdir}/etc/passwd"
|
||||
getent group sshd >> "${initdir}/etc/group"
|
||||
|
||||
mkdir -p -m 0755 "${initdir}$(getent passwd sshd | cut -d':' -f6)"
|
||||
|
||||
systemctl -q --root "${initdir}" enable sshd
|
||||
|
||||
mkdir -p -m 0755 "${initdir}/var/log"
|
||||
touch "${initdir}/var/log/lastlog"
|
||||
|
||||
return 0
|
||||
}
|
||||
19
sys-kernel/dracut-openssh/files/sshd.service
Normal file
19
sys-kernel/dracut-openssh/files/sshd.service
Normal file
@@ -0,0 +1,19 @@
|
||||
[Unit]
|
||||
Description=OpenSSH server daemon
|
||||
DefaultDependencies=no
|
||||
Before=cryptsetup.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
EnvironmentFile=-/etc/sysconfig/sshd
|
||||
|
||||
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
|
||||
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
RestartSec=42s
|
||||
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
||||
10
sys-kernel/dracut-openssh/files/sshd_config
Normal file
10
sys-kernel/dracut-openssh/files/sshd_config
Normal file
@@ -0,0 +1,10 @@
|
||||
SyslogFacility AUTHPRIV
|
||||
PermitRootLogin prohibit-password
|
||||
AuthorizedKeysFile .ssh/authorized_keys
|
||||
AuthenticationMethods publickey
|
||||
UsePAM no
|
||||
X11Forwarding no
|
||||
|
||||
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
|
||||
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
|
||||
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
|
||||
Reference in New Issue
Block a user