Skip to content

Commit 5ed3837

Browse files
infosec-aucplouet
authored andcommitted
feat(ssh): print auth methods
1 parent a408498 commit 5ed3837

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

ssh/client_auth.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@ func (c *connection) clientAuthenticate(config *ClientConfig) error {
6767
// then any untried methods suggested by the server.
6868
var tried []string
6969
var lastMethods []string
70-
70+
var retMethods []string
7171
sessionID := c.transport.getSessionID()
7272
for auth := AuthMethod(new(noneAuth)); auth != nil; {
7373
ok, methods, err := auth.auth(sessionID, config.User, c.transport, config.Rand, extensions)
74+
retMethods = append(retMethods, methods...)
7475
if err != nil {
7576
// On disconnect, return error immediately
7677
if _, ok := err.(*disconnectMsg); ok {
@@ -115,6 +116,13 @@ func (c *connection) clientAuthenticate(config *ClientConfig) error {
115116
return err
116117
}
117118
}
119+
120+
for _, meth := range retMethods {
121+
if strings.ToLower(meth) == "password" {
122+
return fmt.Errorf("password authentication enabled: methods %v", retMethods)
123+
}
124+
}
125+
118126
return fmt.Errorf("ssh: unable to authenticate, attempted methods %v, no supported methods remain", tried)
119127
}
120128

0 commit comments

Comments
 (0)