Files
podman/pkg/machine/keys.go
Paul Holzinger c3a14103fb Fix build tags for pkg/machine...
Podman machine is only intended for amd64 and arm64 architectures, set
the correct buildtags so that the `pkg/machine`, `pkg/machine/qemu` and
`pkg/machine/libvirt` packages compile correctly.

[NO TESTS NEEDED]

Fixes #10625

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-06-10 10:25:16 +02:00

28 lines
658 B
Go

// +build amd64,linux arm64,linux amd64,darwin arm64,darwin
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()
}