From b8a97173e063e7412d79be04e9de4b5cadebb9da Mon Sep 17 00:00:00 2001 From: MicroBlock <66859419+MicroCBer@users.noreply.github.com> Date: Thu, 14 Sep 2023 22:28:25 +0800 Subject: [PATCH] automatically trim keys (#165) --- nixos-infect | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nixos-infect b/nixos-infect index 43c75ea..0875149 100644 --- a/nixos-infect +++ b/nixos-infect @@ -40,9 +40,11 @@ makeConf() { networking.hostName = "$(hostname -s)"; networking.domain = "$(hostname -d)"; services.openssh.enable = true; - users.users.root.openssh.authorizedKeys.keys = [$(while read -r line; do echo -n " - ''$line'' "; done <<< "$keys") - ]; + users.users.root.openssh.authorizedKeys.keys = [$(while read -r line; do + line=$(echo -n "$line" | sed 's/\r//g') + trimmed_line=$(echo -n "$line" | tr -d '[:space:]') + echo -n "''$trimmed_line'' " + done <<< "$keys")]; } EOF