瀏覽代碼

go.crypto/ssh: improve error message when no authentication methods remain

R=golang-dev
CC=golang-dev
https://golang.org/cl/5960044
Dave Cheney 13 年之前
父節點
當前提交
15577f9df4
共有 1 個文件被更改,包括 9 次插入2 次删除
  1. 9 2
      ssh/client_auth.go

+ 9 - 2
ssh/client_auth.go

@@ -5,7 +5,7 @@
 package ssh
 
 import (
-	"errors"
+	"fmt"
 	"io"
 )
 
@@ -52,7 +52,14 @@ func (c *ClientConn) authenticate(session []byte) error {
 			}
 		}
 	}
-	return errors.New("ssh: unable to authenticate, no supported methods remain")
+	return fmt.Errorf("ssh: unable to authenticate, attempted methods %v, no supported methods remain", keys(tried))
+}
+
+func keys(m map[string]bool) (s []string) {
+	for k, _ := range m {
+		s = append(s, k)
+	}
+	return
 }
 
 // A ClientAuth represents an instance of an RFC 4252 authentication method.