From ba98ae112c2f8d7459b2e991daca5cd5a2058e8e Mon Sep 17 00:00:00 2001 From: Gerrit Date: Wed, 15 Jul 2026 09:47:42 +0200 Subject: [PATCH] Add reason flag for firewall SSH. --- cmd/firewall.go | 1 + cmd/ssh.go | 2 ++ docs/metalctl_firewall_ssh.md | 1 + 3 files changed, 4 insertions(+) diff --git a/cmd/firewall.go b/cmd/firewall.go index 472c74e7..f4759fde 100644 --- a/cmd/firewall.go +++ b/cmd/firewall.go @@ -122,6 +122,7 @@ ingress: ValidArgsFunction: c.comp.FirewallListCompletion, } firewallSSHCmd.Flags().StringP("identity", "i", "~/.ssh/id_rsa", "specify identity file to SSH to the firewall like: -i path/to/id_rsa") + firewallSSHCmd.Flags().String("reason", "", "the reason why to connect to the firewall through SSH") return genericcli.NewCmds(cmdsConfig, firewallSSHCmd) } diff --git a/cmd/ssh.go b/cmd/ssh.go index c01b0f93..0c182feb 100644 --- a/cmd/ssh.go +++ b/cmd/ssh.go @@ -9,6 +9,7 @@ import ( "github.com/metal-stack/metal-go/api/client/vpn" "github.com/metal-stack/metal-go/api/models" + "github.com/metal-stack/metal-lib/pkg/pointer" metalssh "github.com/metal-stack/metal-lib/pkg/ssh" metalvpn "github.com/metal-stack/metal-lib/pkg/vpn" "github.com/spf13/viper" @@ -23,6 +24,7 @@ func (c *firewallCmd) firewallSSHViaVPN(firewall *models.V1FirewallResponse) (er authKeyResp, err := c.client.VPN().GetVPNAuthKey(vpn.NewGetVPNAuthKeyParams().WithBody(&models.V1VPNRequest{ Pid: projectID, Ephemeral: new(true), + Reason: pointer.PointerOrNil(viper.GetString("reason")), }), nil) if err != nil { return fmt.Errorf("failed to get VPN auth key: %w", err) diff --git a/docs/metalctl_firewall_ssh.md b/docs/metalctl_firewall_ssh.md index ef2eeb53..728aea37 100644 --- a/docs/metalctl_firewall_ssh.md +++ b/docs/metalctl_firewall_ssh.md @@ -15,6 +15,7 @@ metalctl firewall ssh [flags] ``` -h, --help help for ssh -i, --identity string specify identity file to SSH to the firewall like: -i path/to/id_rsa (default "~/.ssh/id_rsa") + --reason string the reason why to connect to the firewall through SSH ``` ### Options inherited from parent commands