From 43215ff80f7a3eae51f351842021ca9fcd4cc8a3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 25 Apr 2012 14:14:20 +0000 Subject: [PATCH] =?UTF-8?q?*=20In=20the=20implementation=20of=20the=20?= =?UTF-8?q?=E2=80=98authorizedKeys=E2=80=99,=20don't=20delete=20all=20=20?= =?UTF-8?q?=20lines=20below=20a=20certain=20marker.=20=20This=20is=20undes?= =?UTF-8?q?irable=20because=20commands=20=20=20like=20"ssh-copy-id"=20add?= =?UTF-8?q?=20keys=20to=20the=20end=20of=20the=20file.=20=20Instead=20mark?= =?UTF-8?q?=20=20=20all=20automatically=20added=20lines=20individually.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/nixos/trunk/; revision=33918 --- modules/services/networking/ssh/sshd.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/services/networking/ssh/sshd.nix b/modules/services/networking/ssh/sshd.nix index cdb18f9e94e..a47170fb8a7 100644 --- a/modules/services/networking/ssh/sshd.nix +++ b/modules/services/networking/ssh/sshd.nix @@ -73,7 +73,7 @@ let mkAuthkeyScript = let - marker1 = "### NixOS will regenerate this line and every line below it."; + marker1 = "### NixOS auto-added key. Do not edit!"; marker2 = "### NixOS will regenerate this file. Do not edit!"; users = map (userName: getAttr userName config.users.extraUsers) (attrNames config.users.extraUsers); usersWithKeys = flip filter users (u: @@ -98,7 +98,7 @@ let for f in $authKeyFiles; do if [ -f "$f" ]; then - authKeys="$(${pkgs.coreutils}/bin/cat "$f"),$authKeys" + authKeys="$(${pkgs.coreutils}/bin/cat "$f") ${marker1},$authKeys" fi done @@ -110,8 +110,7 @@ let rm -f "$authfile" authKeys="${marker2},$authKeys" else - ${pkgs.gnused}/bin/sed -i '/^### NixOS.*$/,$d' "$authfile" - authKeys="${marker1},$authKeys" + ${pkgs.gnused}/bin/sed -i '/${marker1}/ d' "$authfile" fi for key in $authKeys; do ${pkgs.coreutils}/bin/echo "$key" >> "$authfile"; done fi