Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option for login banner on ssh-portal #442

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading