From 2ab852992fbe85e60fe40e9790ea0c9148cd3478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Cluseau?= Date: Sun, 8 Jul 2018 16:19:53 +1100 Subject: [PATCH] fix: don't change authorized_keys if they are not defined --- pkg/apply/files.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/apply/files.go b/pkg/apply/files.go index 1e1a13d..63e6e11 100644 --- a/pkg/apply/files.go +++ b/pkg/apply/files.go @@ -14,14 +14,16 @@ import ( // Files writes the files from the given config func Files(cfg *config.Config, log *dlog.Log) (err error) { - err = writeFile( - "/root/.ssh/authorized_keys", - []byte(strings.Join(cfg.RootUser.AuthorizedKeys, "\n")), - 0600, 0700, cfg, log, - ) + if cfg.RootUser.AuthorizedKeys != nil { + err = writeFile( + "/root/.ssh/authorized_keys", + []byte(strings.Join(cfg.RootUser.AuthorizedKeys, "\n")), + 0600, 0700, cfg, log, + ) - if err != nil { - return + if err != nil { + return + } } for _, file := range cfg.Files {