From a25149d8a6262aabdfccd18a0396bc398e676131 Mon Sep 17 00:00:00 2001 From: Alex Kelleher <31957457+haak@users.noreply.github.com> Date: Sat, 19 Oct 2024 16:10:14 +0200 Subject: [PATCH] Added default authorized_keys path for Darwin runtime (#71) * update exec.go * update exec.go --- internal/command/exec.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/command/exec.go b/internal/command/exec.go index 4b559d3..e97e8ee 100644 --- a/internal/command/exec.go +++ b/internal/command/exec.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "path/filepath" + "runtime" "sort" "github.com/hashicorp/go-set/v2" @@ -47,8 +48,14 @@ type exec struct { func (e *exec) Execute(args config.Arguments) error { switch args.AuthorizedKeys { case "": - args.AuthorizedKeys = filepath.Join("/home", args.SystemUser, ".ssh", "authorized_keys") - e.logger.Printf("using default output authorized_keys file (%s)", args.AuthorizedKeys) + // check if mac or linux and use different location + if runtime.GOOS == "darwin" { + args.AuthorizedKeys = filepath.Join("/Users", args.SystemUser, ".ssh", "authorized_keys") + } else { + args.AuthorizedKeys = filepath.Join("/home", args.SystemUser, ".ssh", "authorized_keys") + e.logger.Printf("using default output authorized_keys file (%s)", args.AuthorizedKeys) + } + default: e.logger.Printf("using configured output authorized_keys file (%s)", args.AuthorizedKeys) }