summaryrefslogtreecommitdiff
path: root/pkg/machine/keys.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-03-25 10:50:01 -0700
committerGitHub <noreply@github.com>2021-03-25 10:50:01 -0700
commitdb356748738762c31a036c179d23488d7978dabf (patch)
treea01d257cba3349b47ff743b11eaa7f496bac991b /pkg/machine/keys.go
parent24581d8760691af1657c4f890d42ebd76f5e85c4 (diff)
parent4ab8a6f67eb9de0de40d478cb0cbec05b1b725c0 (diff)
downloadpodman-db356748738762c31a036c179d23488d7978dabf.tar.gz
podman-db356748738762c31a036c179d23488d7978dabf.tar.bz2
podman-db356748738762c31a036c179d23488d7978dabf.zip
Merge pull request #9781 from baude/addqemu
introduce podman machine
Diffstat (limited to 'pkg/machine/keys.go')
-rw-r--r--pkg/machine/keys.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/machine/keys.go b/pkg/machine/keys.go
new file mode 100644
index 000000000..907e28f55
--- /dev/null
+++ b/pkg/machine/keys.go
@@ -0,0 +1,25 @@
+package machine
+
+import (
+ "io/ioutil"
+ "os/exec"
+ "strings"
+)
+
+// CreateSSHKeys makes a priv and pub ssh key for interacting
+// the a VM.
+func CreateSSHKeys(writeLocation string) (string, error) {
+ if err := generatekeys(writeLocation); err != nil {
+ return "", err
+ }
+ b, err := ioutil.ReadFile(writeLocation + ".pub")
+ if err != nil {
+ return "", err
+ }
+ return strings.TrimSuffix(string(b), "\n"), nil
+}
+
+// generatekeys creates an ed25519 set of keys
+func generatekeys(writeLocation string) error {
+ return exec.Command("ssh-keygen", "-N", "", "-t", "ed25519", "-f", writeLocation).Run()
+}