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

Commit

Permalink
The multi-hypervisor refactor lost the ssh key creation code.
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenDowideit committed Aug 22, 2014
1 parent 22b11f1 commit d7b0e1b
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

4 comments on commit d7b0e1b

@ches
Copy link

@ches ches commented on d7b0e1b Aug 30, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So key creation is missing in the 1.2.0 release, correct? I just installed from Homebrew on a brand new system and found boot2docker init broken out of the box. brew install boot2docker --HEAD to include this change has fixed it. Bumping a release for distribution seems like a considerate move 😔

@SvenDowideit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the key creation code is not missing from 1.2.0 - if you download the boot2docker v1.2.0 release, you'll see its based on Git commit: a551732, which if you review https://github.com/boot2docker/boot2docker-cli/commits/master is the merge that contains this code.

I am however a little puzzled by the v1.2.0 git tag - which doesn't include it, which may be what is throwing off brew?

@SvenDowideit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and now I've forced the tag - if you know how to get brew to bump a release please do.

@ches
Copy link

@ches ches commented on d7b0e1b Sep 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-reference for anyone who may happen to land here: Homebrew binaries are now rebuilt following the revision tag change. See also boot2docker/boot2docker#509. Thanks Sven!

Please sign in to comment.