# HG changeset patch # User weyllor # Date 1396277749 -28800 # Mon Mar 31 22:55:49 2014 +0800 # Node ID 2c103903d00e4c547d644426532ed3ef1016a77e # Parent 7aa593ce8ceaf0199504fff27455bbb60eedabc7 add suggested auth methos from server to error info diff --git a/ssh/client_auth.go b/ssh/client_auth.go --- a/ssh/client_auth.go +++ b/ssh/client_auth.go @@ -27,7 +27,7 @@ } // during the authentication phase the client first attempts the "none" method // then any untried methods suggested by the server. - tried, remain := make(map[string]bool), make(map[string]bool) + suggested, tried, remain := make(map[string]bool), make(map[string]bool), make(map[string]bool) for auth := ClientAuth(new(noneAuth)); auth != nil; { ok, methods, err := auth.auth(c.transport.sessionID, c.config.User, c.transport, c.config.rand()) if err != nil { @@ -44,6 +44,7 @@ // if we've tried meth already, skip it. continue } + suggested[meth] = true remain[meth] = true } auth = nil @@ -54,7 +55,7 @@ } } } - return fmt.Errorf("ssh: unable to authenticate, attempted methods %v, no supported methods remain", keys(tried)) + return fmt.Errorf("ssh: unable to authenticate, suggested methods %v, attempted methods %v, no supported methods remain", keys(suggested), keys(tried)) } func keys(m map[string]bool) (s []string) {