diff --git a/auth.go b/auth.go index bf70a896..c5dee6af 100644 --- a/auth.go +++ b/auth.go @@ -5,7 +5,9 @@ import ( "bytes" "errors" "io" + "os" "os/user" + "strconv" ) // AuthStatus represents the Status of an authentication mechanism. @@ -52,11 +54,12 @@ type Auth interface { // bus. Auth must not be called on shared connections. func (conn *Conn) Auth(methods []Auth) error { if methods == nil { + uid := strconv.Itoa(os.Getuid()) u, err := user.Current() if err != nil { return err } - methods = []Auth{AuthExternal(u.Username), AuthCookieSha1(u.Username, u.HomeDir)} + methods = []Auth{AuthExternal(uid), AuthCookieSha1(uid, u.HomeDir)} } in := bufio.NewReader(conn.transport) err := conn.transport.SendNullByte()