aboutsummaryrefslogtreecommitdiffstats
path: root/clients/ssh/auth_method.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-31 23:42:36 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-31 23:42:36 +0200
commit5bed3e8fab965738f3f55bb01d15cd4748c26066 (patch)
tree14dbeb9f92b4ab16ab99268156c3336b53bcfce4 /clients/ssh/auth_method.go
parenta82239a71a2cfc7a55af253d11c28fcec73a3039 (diff)
downloadgo-git-5bed3e8fab965738f3f55bb01d15cd4748c26066.tar.gz
clients: default Auth methods
Diffstat (limited to 'clients/ssh/auth_method.go')
-rw-r--r--clients/ssh/auth_method.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/clients/ssh/auth_method.go b/clients/ssh/auth_method.go
index e55283e..1ce45ef 100644
--- a/clients/ssh/auth_method.go
+++ b/clients/ssh/auth_method.go
@@ -138,16 +138,22 @@ func (a *PublicKeysCallback) clientConfig() *ssh.ClientConfig {
}
}
+const DefaultSSHUsername = "git"
+
// Opens a pipe with the ssh agent and uses the pipe
// as the implementer of the public key callback function.
-func NewSSHAgentAuth() (*PublicKeysCallback, error) {
+func NewSSHAgentAuth(user string) (*PublicKeysCallback, error) {
+ if user == "" {
+ user = DefaultSSHUsername
+ }
+
pipe, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
if err != nil {
return nil, err
}
return &PublicKeysCallback{
- User: "git",
+ User: user,
Callback: agent.NewClient(pipe).Signers,
}, nil
}