Skip to content

Commit

Permalink
chore: Adding support to ssh-agent on Windows using named pipes (#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrangelramos authored Jan 5, 2022
1 parent e0b5adc commit 3177287
Show file tree
Hide file tree
Showing 13 changed files with 1,203 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ require (
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.7 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.21.4
k8s.io/apimachinery v0.21.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1780,6 +1780,8 @@ gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
Expand Down
12 changes: 12 additions & 0 deletions ssh/ssh_agent_conf.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build !windows
// +build !windows

package ssh

import (
"net"
)

func dialSSHAgentConnection(sock string) (agentConn net.Conn, error error) {
return net.Dial("unix", sock)
}
17 changes: 17 additions & 0 deletions ssh/ssh_agent_conf_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ssh

import (
"net"
"strings"

"gopkg.in/natefinch/npipe.v2"
)

func dialSSHAgentConnection(sock string) (agentConn net.Conn, error error) {
if strings.Contains(sock, "\\pipe\\") {
agentConn, error = npipe.Dial(sock)
} else {
agentConn, error = net.Dial("unix", sock)
}
return
}
2 changes: 1 addition & 1 deletion ssh/ssh_dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func NewSSHClientConfig(url *urlPkg.URL, credentialsConfig Config) (*ssh.ClientC
if sock, found := os.LookupEnv("SSH_AUTH_SOCK"); found && sock != "" {
var agentSigners []ssh.Signer
var agentConn net.Conn
agentConn, err = net.Dial("unix", sock)
agentConn, err = dialSSHAgentConnection(sock)
if err != nil {
return nil, fmt.Errorf("failed to connect to ssh-agent's socket: %w", err)
}
Expand Down
22 changes: 22 additions & 0 deletions vendor/gopkg.in/natefinch/npipe.v2/.gitignore

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

8 changes: 8 additions & 0 deletions vendor/gopkg.in/natefinch/npipe.v2/LICENSE.txt

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

308 changes: 308 additions & 0 deletions vendor/gopkg.in/natefinch/npipe.v2/README.md

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

Loading

0 comments on commit 3177287

Please sign in to comment.