Skip to content

Commit

Permalink
Generate full assh binary path in ~/.ssh/config (fix #148)
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed May 2, 2017
1 parent 17e9893 commit 95cb1b2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ Host *
* Add RateLimit support ([#65](https://github.com/moul/advanced-ssh-config/issues/65))
* Add possibility to disable automatic configuration rewrite ([#239](https://github.com/moul/advanced-ssh-config/issues/239))
* Add `BeforeConfigWrite` and `AfterConfigWrite` new hooks ([#239](https://github.com/moul/advanced-ssh-config/issues/239))
* Generate full assh binary path in ~/.ssh/config ([#148](https://github.com/moul/advanced-ssh-config/issues/148))

[Full commits list](https://github.com/moul/advanced-ssh-config/compare/v2.6.0...master)

Expand Down
12 changes: 11 additions & 1 deletion pkg/commands/commands.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
package commands

import (
"log"
"os"
"path/filepath"

"github.com/moul/advanced-ssh-config/pkg/config"
"github.com/urfave/cli"
// . "github.com/moul/advanced-ssh-config/pkg/logger"
)

func init() {
config.SetASSHBinaryPath(os.Args[0])
ex, err := os.Executable()
if err != nil {
log.Fatal(err)
}
abspath, err := filepath.Abs(ex)
if err != nil {
log.Fatal(err)
}
config.SetASSHBinaryPath(abspath)
}

// Commands is the list of cli commands
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -44,6 +45,7 @@ func (c *Config) DisableAutomaticRewrite() {
// SetASSHBinaryPath sets the default assh binary path
// this value may be overwritten in the assh.yml file using the asshbinarypath variable
func SetASSHBinaryPath(path string) {
log.Println(path)
asshBinaryPath = path
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/config/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"os/user"
"strings"

Expand Down Expand Up @@ -1378,6 +1379,7 @@ func (h *Host) WriteSSHConfigTo(w io.Writer) error {

// ssh-config fields with a different behavior
if h.isDefault {
log.Println(asshBinaryPath)
if h.noAutomaticRewrite {
fmt.Fprintf(w, " ProxyCommand %s connect --no-rewrite --port=%%p %%h\n", asshBinaryPath)
} else {
Expand Down

0 comments on commit 95cb1b2

Please sign in to comment.