Skip to content

Commit fb70331

Browse files
committed
fix: enforce password login when public key authentication fails
1 parent ae168e6 commit fb70331

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

mods/server/ssh.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ func (svr *sshd) publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
289289
// and then web terminal is connected with password?
290290
// In this case, the ssh session should be updated with the password in the context.
291291
svr.log.Tracef("'%s' login with public key, but password is not found in the auth server", user)
292+
valid = false // force to login with password
292293
}
293294
}
294295
return valid
@@ -394,19 +395,6 @@ func (svr *sshd) commandHandler(ss ssh.Session) {
394395
return
395396
}
396397

397-
// if cmd := ss.Command(); len(cmd) > 0 && cmd[0] == "jsh" {
398-
// jsCmd := "@.js"
399-
// jsArgs := []string{}
400-
// if len(cmd) > 1 {
401-
// jsCmd = cmd[1]
402-
// }
403-
// if len(cmd) > 2 {
404-
// jsArgs = cmd[2:]
405-
// }
406-
// svr.jshHandler(ss, jsCmd, jsArgs, shell.Envs)
407-
// return
408-
// }
409-
410398
if shellId == model.SHELLID_SHELL {
411399
shell.Envs = append(shell.Envs, fmt.Sprintf("NEOSHELL_USER=%s", user))
412400
shell.Envs = append(shell.Envs, fmt.Sprintf("NEOSHELL_PASSWORD=%s", svr.authServer.neoShellAccount[strings.ToLower(user)]))

0 commit comments

Comments
 (0)