blob: 907e28f5501ba29b04ef5a705eb4c7791de6c0c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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()
}
|