Skip to content

Commit

Permalink
Merge pull request #442 from uselagoon/banner
Browse files Browse the repository at this point in the history
feat: add option for login banner on ssh-portal
  • Loading branch information
smlx authored May 13, 2024
2 parents f1df832 + fdbb78b commit 6d517c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/ssh-portal/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ type ServeCmd struct {
HostKeyECDSA string `kong:"env='HOST_KEY_ECDSA',help='PEM encoded ECDSA host key'"`
HostKeyED25519 string `kong:"env='HOST_KEY_ED25519',help='PEM encoded Ed25519 host key'"`
HostKeyRSA string `kong:"env='HOST_KEY_RSA',help='PEM encoded RSA host key'"`
LogAccessEnabled bool `kong:"env='LOG_ACCESS_ENABLED',help='Allow any user who can SSH into a pod to also access its logs.'"`
LogAccessEnabled bool `kong:"env='LOG_ACCESS_ENABLED',help='Allow any user who can SSH into a pod to also access its logs'"`
Banner string `kong:"env='BANNER',help='Text sent to remote users before authentication'"`
}

// Run the serve command to handle SSH connection requests.
Expand Down Expand Up @@ -81,7 +82,8 @@ func (cmd *ServeCmd) Run(log *slog.Logger) error {
// start serving SSH token requests
eg.Go(func() error {
// start serving SSH connection requests
return sshserver.Serve(ctx, log, nc, l, c, hostkeys, cmd.LogAccessEnabled)
return sshserver.Serve(
ctx, log, nc, l, c, hostkeys, cmd.LogAccessEnabled, cmd.Banner)
})
return eg.Wait()
}
2 changes: 2 additions & 0 deletions internal/sshserver/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func Serve(
c *k8s.Client,
hostKeys [][]byte,
logAccessEnabled bool,
banner string,
) error {
srv := ssh.Server{
Handler: sessionHandler(log, c, false, logAccessEnabled),
Expand All @@ -53,6 +54,7 @@ func Serve(
},
PublicKeyHandler: pubKeyAuth(log, nc, c),
ServerConfigCallback: disableSHA1Kex,
Banner: banner,
}
for _, hk := range hostKeys {
if err := srv.SetOption(ssh.HostKeyPEM(hk)); err != nil {
Expand Down

0 comments on commit 6d517c0

Please sign in to comment.