Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,32 @@ func initAuthMethod() {
var signers []ssh.Signer

// If there's a running SSH Agent, try to use its Private keys.
sock, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
if err == nil {
agent := agent.NewClient(sock)
signers, _ = agent.Signers()
sockPath := os.Getenv("SSH_AUTH_SOCK")
if len(sockPath) > 0 {
sock, err := net.Dial("unix", sockPath)
if err == nil {
agent := agent.NewClient(sock)
signers, _ = agent.Signers()
} else {
fmt.Printf("warning: couldn't connect to SSH_AUTH_SOCK (%s)\n", err)
}
}

// Try to read user's SSH private keys form the standard paths.
files, _ := filepath.Glob(os.Getenv("HOME") + "/.ssh/id_*")
for _, file := range files {
fmt.Println("applepear1 keyfile candidate", file)
if strings.HasSuffix(file, ".pub") {
continue // Skip public keys.
}
data, err := ioutil.ReadFile(file)
if err != nil {
fmt.Printf("warning: not importing unreadable key %s (%s)\n", file, err)
continue
}
signer, err := ssh.ParsePrivateKey(data)
if err != nil {
fmt.Printf("warning: not importing misformatted key %s (%s)\n", file, err)
continue
}
signers = append(signers, signer)
Expand Down Expand Up @@ -139,6 +147,7 @@ func (c *SSHClient) ConnectWith(host string, dialer SSHDialFunc) error {
Auth: []ssh.AuthMethod{
authMethod,
},
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}

c.conn, err = dialer("tcp", c.host, config)
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/mikkeloscar/sshconfig/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 33 additions & 3 deletions vendor/github.com/mikkeloscar/sshconfig/lex.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/mikkeloscar/sshconfig/parser.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions vendor/github.com/pkg/errors/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions vendor/github.com/pkg/errors/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading