From 5f04f9961a6e18603d30b8b7aa415f9607d2f945 Mon Sep 17 00:00:00 2001 From: Ashley Cui Date: Fri, 15 Jul 2022 15:20:16 -0400 Subject: Machine init: create .ssh dir if not exist When initing a machine, we generate ssh keys in `$HOME/.ssh`. If there is not .ssh dir, we should create it, so the init does not fail. Signed-off-by: Ashley Cui --- pkg/machine/keys.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pkg/machine') diff --git a/pkg/machine/keys.go b/pkg/machine/keys.go index 0c7d7114e..94cbdac04 100644 --- a/pkg/machine/keys.go +++ b/pkg/machine/keys.go @@ -21,6 +21,9 @@ var sshCommand = []string{"ssh-keygen", "-N", "", "-t", "ed25519", "-f"} // CreateSSHKeys makes a priv and pub ssh key for interacting // the a VM. func CreateSSHKeys(writeLocation string) (string, error) { + if err := os.MkdirAll(filepath.Dir(writeLocation), 0700); err != nil { + return "", err + } if err := generatekeys(writeLocation); err != nil { return "", err } -- cgit v1.2.3-54-g00ecf