diff --git a/etc/warewulf.conf b/etc/warewulf.conf index 1c998b3d..a9afbccb 100644 --- a/etc/warewulf.conf +++ b/etc/warewulf.conf @@ -38,3 +38,9 @@ container mounts: - source: /etc/resolv.conf dest: /etc/resolv.conf readonly: true +ssh: + key types: + - rsa + - dsa + - ecdsa + - ed25519 diff --git a/internal/app/wwctl/configure/root.go b/internal/app/wwctl/configure/root.go index dd78e436..40a84e02 100644 --- a/internal/app/wwctl/configure/root.go +++ b/internal/app/wwctl/configure/root.go @@ -28,7 +28,7 @@ func init() { baseCmd.AddCommand(nfs.GetCommand()) baseCmd.AddCommand(hostfile.GetCommand()) - baseCmd.PersistentFlags().BoolVarP(&allFunctions, "all", "a", false, "Configure all services") + baseCmd.Flags().BoolVarP(&allFunctions, "all", "a", false, "Configure all services") } // GetRootCommand returns the root cobra.Command for the application. diff --git a/internal/app/wwctl/configure/ssh/main.go b/internal/app/wwctl/configure/ssh/main.go index e2db9aba..e73e13f4 100644 --- a/internal/app/wwctl/configure/ssh/main.go +++ b/internal/app/wwctl/configure/ssh/main.go @@ -2,9 +2,13 @@ package ssh import ( "github.com/spf13/cobra" + warewulfconf "github.com/warewulf/warewulf/internal/pkg/config" "github.com/warewulf/warewulf/internal/pkg/configure" ) func CobraRunE(cmd *cobra.Command, args []string) error { + if len(keyTypes) == 0 { + keyTypes = append(keyTypes, warewulfconf.Get().SSH.KeyTypes...) + } return configure.SSH(keyTypes...) } diff --git a/internal/app/wwctl/configure/ssh/root.go b/internal/app/wwctl/configure/ssh/root.go index cd08db39..9e56b6ae 100644 --- a/internal/app/wwctl/configure/ssh/root.go +++ b/internal/app/wwctl/configure/ssh/root.go @@ -1,6 +1,8 @@ package ssh -import "github.com/spf13/cobra" +import ( + "github.com/spf13/cobra" +) var ( baseCmd = &cobra.Command{ @@ -20,6 +22,6 @@ func init() { // GetRootCommand returns the root cobra.Command for the application. func GetCommand() *cobra.Command { - baseCmd.PersistentFlags().StringArrayVarP(&keyTypes, "keytypes", "t", []string{"rsa", "dsa", "ecdsa", "ed25519"}, "ssh key types to be created") + baseCmd.PersistentFlags().StringArrayVarP(&keyTypes, "keytypes", "t", []string{}, "ssh key types to be created") return baseCmd } diff --git a/internal/pkg/config/root.go b/internal/pkg/config/root.go index e8369f14..97f26b98 100644 --- a/internal/pkg/config/root.go +++ b/internal/pkg/config/root.go @@ -38,6 +38,7 @@ type RootConf struct { DHCP *DHCPConf `yaml:"dhcp"` TFTP *TFTPConf `yaml:"tftp"` NFS *NFSConf `yaml:"nfs"` + SSH *SSHConf `yaml:"ssh,omitempty"` MountsContainer []*MountEntry `yaml:"container mounts" default:"[{\"source\": \"/etc/resolv.conf\", \"dest\": \"/etc/resolv.conf\"}]"` Paths *BuildConfig `yaml:"paths"` @@ -53,6 +54,7 @@ func New() *RootConf { cachedConf.DHCP = new(DHCPConf) cachedConf.TFTP = new(TFTPConf) cachedConf.NFS = new(NFSConf) + cachedConf.SSH = new(SSHConf) cachedConf.Paths = new(BuildConfig) if err := defaults.Set(&cachedConf); err != nil { panic(err) diff --git a/internal/pkg/config/ssh.go b/internal/pkg/config/ssh.go new file mode 100644 index 00000000..a9abe4dc --- /dev/null +++ b/internal/pkg/config/ssh.go @@ -0,0 +1,5 @@ +package config + +type SSHConf struct { + KeyTypes []string `yaml:"key types" default:"[\"rsa\",\"dsa\",\"ecdsa\",\"ed25519\"]"` +}