summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorAshley Cui <acui@redhat.com>2022-07-15 15:20:16 -0400
committerMatthew Heon <matthew.heon@pm.me>2022-07-26 13:29:40 -0400
commite473c5e4b741cef2c1174cb4ec51000f443e6877 (patch)
tree0ac07a3944e0f32e1763a4f34d4d5000364afe34 /pkg
parent53edd9b654d558ff769286ef948ab0f6a23c68cc (diff)
downloadpodman-e473c5e4b741cef2c1174cb4ec51000f443e6877.tar.gz
podman-e473c5e4b741cef2c1174cb4ec51000f443e6877.tar.bz2
podman-e473c5e4b741cef2c1174cb4ec51000f443e6877.zip
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 <acui@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/machine/keys.go3
1 files changed, 3 insertions, 0 deletions
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
}