aboutsummaryrefslogtreecommitdiffstats
path: root/clients/ssh/auth_method.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-24 20:40:33 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-24 22:00:44 +0200
commit0fa6f26b0e6ca242088794027c0a32d01e1bc6f9 (patch)
tree40b294855cd5b8fe28fe97786ce953c6704ca601 /clients/ssh/auth_method.go
parent9ae3c5808fcfa468d1f9394c9b16bc02f573ba79 (diff)
downloadgo-git-0fa6f26b0e6ca242088794027c0a32d01e1bc6f9.tar.gz
clients/ssh: test fix
Diffstat (limited to 'clients/ssh/auth_method.go')
-rw-r--r--clients/ssh/auth_method.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/clients/ssh/auth_method.go b/clients/ssh/auth_method.go
index 4fe68ca..e55283e 100644
--- a/clients/ssh/auth_method.go
+++ b/clients/ssh/auth_method.go
@@ -2,8 +2,11 @@ package ssh
import (
"fmt"
+ "net"
+ "os"
"golang.org/x/crypto/ssh"
+ "golang.org/x/crypto/ssh/agent"
"gopkg.in/src-d/go-git.v4/clients/common"
)
@@ -134,3 +137,17 @@ func (a *PublicKeysCallback) clientConfig() *ssh.ClientConfig {
Auth: []ssh.AuthMethod{ssh.PublicKeysCallback(a.Callback)},
}
}
+
+// Opens a pipe with the ssh agent and uses the pipe
+// as the implementer of the public key callback function.
+func NewSSHAgentAuth() (*PublicKeysCallback, error) {
+ pipe, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
+ if err != nil {
+ return nil, err
+ }
+
+ return &PublicKeysCallback{
+ User: "git",
+ Callback: agent.NewClient(pipe).Signers,
+ }, nil
+}