Skip to content

Commit

Permalink
Added default authorized_keys path for Darwin runtime (#71)
Browse files Browse the repository at this point in the history
* update exec.go

* update exec.go
  • Loading branch information
haak authored Oct 19, 2024
1 parent 55279f9 commit a25149d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/command/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"path/filepath"
"runtime"
"sort"

"github.com/hashicorp/go-set/v2"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit a25149d

Please sign in to comment.