Skip to content

Commit

Permalink
create parent .ssh dir if it doesnt exist
Browse files Browse the repository at this point in the history
  • Loading branch information
sgsullivan committed Aug 4, 2022
1 parent ef66f96 commit 4fdf9b6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion getters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ func getZeroValOpts() *Instance {
})
}

var defaultKnownHosts = os.Getenv("HOME") + "/.ssh/known_hosts"
var defaultSshPath = os.Getenv("HOME") + "/.ssh"
var defaultKnownHosts = defaultSshPath + "/known_hosts"

func init() {
if !filesystem.PathExists(defaultSshPath) {
if err := os.Mkdir(defaultSshPath, os.ModePerm); err != nil {
panic(fmt.Sprintf("failed to create %s: %s", defaultSshPath, err))
}
}

if !filesystem.FileExists(defaultKnownHosts) {
f, err := os.Create(defaultKnownHosts)
if err != nil {
Expand Down

0 comments on commit 4fdf9b6

Please sign in to comment.