tinyssh gen host keys

This commit is contained in:
Dominik Moritz Roth 2025-08-18 01:02:54 +02:00
parent 059a926da6
commit 70bd757166

View File

@ -106,6 +106,10 @@ dnf install -y \
tmux neovim python3-pip \
tree gcc make autoconf automake tar bzip2 || exit 1
# Install tinyssh-keyconvert
echo "[+] Installing tinyssh-keyconvert..."
pip3 install git+https://github.com/ansemjo/tinyssh-keyconvert.git || echo "WARNING: tinyssh-keyconvert install failed"
# Build and install tinyssh from source since AlmaLinux doesn't package it
echo "[+] Installing tinyssh from source..."
cd /tmp || exit 1
@ -255,11 +259,18 @@ mkdir -p /etc/tinyssh/sshkeydir
echo "${SSH_KEY}" > /etc/tinyssh/authorized_keys
chmod 600 /etc/tinyssh/authorized_keys
# Generate host keys using OpenSSH then convert to tinyssh format
ssh-keygen -A
for key in /etc/ssh/ssh_host_*_key; do
[ -f "$key" ] && tinyssh-keyconvert "$key" /etc/tinyssh/sshkeydir/
done
# Generate host keys using tinyssh directly
/usr/local/bin/tinysshd-makekey /etc/tinyssh/sshkeydir || {
echo "WARNING: Failed to generate tinyssh keys, falling back to OpenSSH conversion"
ssh-keygen -A
if command -v tinyssh-keyconvert >/dev/null 2>&1; then
for key in /etc/ssh/ssh_host_*_key; do
[ -f "$key" ] && tinyssh-keyconvert "$key" /etc/tinyssh/sshkeydir/
done
else
echo "ERROR: tinyssh-keyconvert not available and tinysshd-makekey failed"
fi
}
# Configure dracut
cat > /etc/dracut.conf.d/99-tinyssh.conf << 'EOF'