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

Commit

Permalink
Merge pull request #231 from SvenDowideit/refactor-lost-ssh-key-creation
Browse files Browse the repository at this point in the history
The multi-hypervisor refactor lost the ssh key creation code.
  • Loading branch information
Sven Dowideit authored and Sven Dowideit committed Aug 22, 2014
2 parents 22b11f1 + d7b0e1b commit 9a5a503
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"encoding/json"
"fmt"
"os"
"os/exec"
"runtime"
"strings"
"time"

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

// Initialize the boot2docker VM from scratch.
func cmdInit() error {

if _, err := os.Stat(B2D.SSHKey); err != nil {
if !os.IsNotExist(err) {
return fmt.Errorf("Something wrong with SSH Key file %q: %s", B2D.SSHKey, err)
}

cmd := exec.Command(B2D.SSHGen, "-t", "rsa", "-N", "", "-f", B2D.SSHKey)
if B2D.Verbose {
cmd.Stderr = os.Stderr
fmt.Printf("executing: %v %v", cmd.Path, strings.Join(cmd.Args, " "))
}
b, err := cmd.Output()
if err != nil {
return fmt.Errorf("Error generating new SSH Key into %s: %s", B2D.SSHKey, err)
}
out := string(b)
if B2D.Verbose {
fmt.Printf("%s returned: %s\nEND\n", B2D.SSHKey, out)
}
}
//TODO: print a ~/.ssh/config entry for our b2d connection that the user can c&p

B2D.Init = true
_, err := driver.GetMachine(&B2D)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func getSSHCommand(m driver.Machine, args ...string) *exec.Cmd {
cmd := exec.Command(B2D.SSH, sshArgs...)
if B2D.Verbose {
cmd.Stderr = os.Stderr
log.Printf("executing: %v %v", B2D.SSH, strings.Join(sshArgs, " "))
log.Printf("executing: %v %v", cmd.Path, strings.Join(cmd.Args, " "))
}

return cmd
Expand Down

0 comments on commit 9a5a503

Please sign in to comment.