Skip to content

Commit

Permalink
feat: allow to set a server banner
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Jan 4, 2024
1 parent 7de97f6 commit 973b62f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Server struct {
Handler Handler // handler to invoke, ssh.DefaultHandler if nil
HostSigners []Signer // private keys for the host key, must have at least one
Version string // server version to be sent before the initial handshake
Banner string // server banner

KeyboardInteractiveHandler KeyboardInteractiveHandler // keyboard-interactive authentication handler
PasswordHandler PasswordHandler // password authentication handler
Expand Down Expand Up @@ -132,6 +133,11 @@ func (srv *Server) config(ctx Context) *gossh.ServerConfig {
if srv.Version != "" {
config.ServerVersion = "SSH-2.0-" + srv.Version
}
if srv.Banner != "" {
config.BannerCallback = func(conn gossh.ConnMetadata) string {
return srv.Banner
}
}
if srv.PasswordHandler != nil {
config.PasswordCallback = func(conn gossh.ConnMetadata, password []byte) (*gossh.Permissions, error) {
applyConnMetadata(ctx, conn)
Expand Down

0 comments on commit 973b62f

Please sign in to comment.