Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Commit d7b0e1b

Browse files
committed
The multi-hypervisor refactor lost the ssh key creation code.
1 parent 22b11f1 commit d7b0e1b

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

cmds.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"encoding/json"
55
"fmt"
66
"os"
7+
"os/exec"
78
"runtime"
9+
"strings"
810
"time"
911

1012
_ "github.com/boot2docker/boot2docker-cli/dummy"
@@ -15,6 +17,28 @@ import (
1517

1618
// Initialize the boot2docker VM from scratch.
1719
func cmdInit() error {
20+
21+
if _, err := os.Stat(B2D.SSHKey); err != nil {
22+
if !os.IsNotExist(err) {
23+
return fmt.Errorf("Something wrong with SSH Key file %q: %s", B2D.SSHKey, err)
24+
}
25+
26+
cmd := exec.Command(B2D.SSHGen, "-t", "rsa", "-N", "", "-f", B2D.SSHKey)
27+
if B2D.Verbose {
28+
cmd.Stderr = os.Stderr
29+
fmt.Printf("executing: %v %v", cmd.Path, strings.Join(cmd.Args, " "))
30+
}
31+
b, err := cmd.Output()
32+
if err != nil {
33+
return fmt.Errorf("Error generating new SSH Key into %s: %s", B2D.SSHKey, err)
34+
}
35+
out := string(b)
36+
if B2D.Verbose {
37+
fmt.Printf("%s returned: %s\nEND\n", B2D.SSHKey, out)
38+
}
39+
}
40+
//TODO: print a ~/.ssh/config entry for our b2d connection that the user can c&p
41+
1842
B2D.Init = true
1943
_, err := driver.GetMachine(&B2D)
2044
if err != nil {

util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func getSSHCommand(m driver.Machine, args ...string) *exec.Cmd {
183183
cmd := exec.Command(B2D.SSH, sshArgs...)
184184
if B2D.Verbose {
185185
cmd.Stderr = os.Stderr
186-
log.Printf("executing: %v %v", B2D.SSH, strings.Join(sshArgs, " "))
186+
log.Printf("executing: %v %v", cmd.Path, strings.Join(cmd.Args, " "))
187187
}
188188

189189
return cmd

0 commit comments

Comments
 (0)