From bbe94a11758e4a0ab1ff9f5a1f512dc0b4ae9fd6 Mon Sep 17 00:00:00 2001 From: Dominik Gleich Date: Mon, 11 Mar 2024 16:34:16 +0100 Subject: [PATCH] fix: Authorized keys parsing and extraction (#187) * add support for SK authorized keys nixos-infect incorrectly handles * Update nixos-infect * Replace space with [[:space:]] * Fix possible security issue --- nixos-infect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos-infect b/nixos-infect index a190d7f..77a3769 100644 --- a/nixos-infect +++ b/nixos-infect @@ -26,7 +26,7 @@ makeConf() { local IFS=$'\n' for trypath in /root/.ssh/authorized_keys /home/$SUDO_USER/.ssh/authorized_keys $HOME/.ssh/authorized_keys; do [[ -r "$trypath" ]] \ - && keys=$(sed -E 's/^.*((ssh|ecdsa)-[^[:space:]]+)[[:space:]]+([^[:space:]]+)([[:space:]]*.*)$/\1 \3\4/' "$trypath") \ + && keys=$(sed -E 's/^[^#].*[[:space:]]((sk-ssh|sk-ecdsa|ssh|ecdsa)-[^[:space:]]+)[[:space:]]+([^[:space:]]+)([[:space:]]*.*)$/\1 \3\4/' "$trypath") \ && [[ ! -z "$keys" ]] \ && break done