Skip to content

proposal: x/crypto/ssh: dynamic auth method selection in ServerConfig #64974

Closed
@awly

Description

@awly

Proposal Details

Today, when an auth method fails, server returns a SSH_MSG_USERAUTH_FAILURE with a set of possible methods that the client can attempt next. This set of methods is based on what auth callbacks are set in the ServerConfig.

The proposal is to add a new callback that allows for customizing this set of auth methods per connection, based on previous errors:

type ServerConfig struct
	...

	// NextAuthMethodCallback, if non-nil, is called whenever an authentication
	// method fails. It's called after AuthLogCallback, if set. The return
	// values are the SSH auth types (from
	// https://www.iana.org/assignments/ssh-parameters/ssh-parameters.xhtml#ssh-parameters-10
	// such as "password", "publickey", "keyboard-interactive", etc)
	// to suggest for the client to try next. If empty, authentication fails.
	NextAuthMethodCallback func(conn ConnMetadata, prevErrors []error) []string
}

An example use case: using NoClientAuthCallback to learn some information about the client and then selectively enable a subset of auth methods that could succeed for them.
Another use case: when using an out-of-band authentication mechanism (such as an authenticated tunnel that carries the SSH connection), NextAuthMethodCallback can return a custom auth method name to the client, as an indication of where authentication failed.

cc @bradfitz @maisem

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions