Skip to content

Commit 33b7cde

Browse files
committed
feat(ssh): print auth methods
1 parent 711faa5 commit 33b7cde

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

ssh/client_auth.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,11 @@ func (c *connection) clientAuthenticate(config *ClientConfig) error {
6666
// then any untried methods suggested by the server.
6767
var tried []string
6868
var lastMethods []string
69-
69+
var retMethods []string
7070
sessionID := c.transport.getSessionID()
7171
for auth := AuthMethod(new(noneAuth)); auth != nil; {
7272
ok, methods, err := auth.auth(sessionID, config.User, c.transport, config.Rand, extensions)
73-
fmt.Printf("methods available: %v\n", methods)
74-
for _, meth := range methods {
75-
if strings.ToLower(meth) == "password" {
76-
fmt.Println("password authentication enabled on this server")
77-
}
78-
}
73+
retMethods = append(retMethods, methods...)
7974
if err != nil {
8075
return err
8176
}
@@ -108,6 +103,13 @@ func (c *connection) clientAuthenticate(config *ClientConfig) error {
108103
}
109104
}
110105
}
106+
107+
for _, meth := range retMethods {
108+
if strings.ToLower(meth) == "password" {
109+
return fmt.Errorf("password authentication enabled: methods %v", retMethods)
110+
}
111+
}
112+
111113
return fmt.Errorf("ssh: unable to authenticate, attempted methods %v, no supported methods remain", tried)
112114
}
113115

0 commit comments

Comments
 (0)