mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00

podman machine allows podman to create, manage, and interact with a vm running some form of linux (default is fcos). podman is then configured to be able to interact with the vm automatically. while this is usable on linux, the real push is to get this working on both current apple architectures in macos. Ashley Cui contributed to this PR and was a great help. [NO TESTS NEEDED] Signed-off-by: baude <bbaude@redhat.com>
26 lines
597 B
Go
26 lines
597 B
Go
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()
|
|
}
|