diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c4dcfa5..19869eb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## v4.5.2, unreleased +### Added + +- Allow specification of the ssh-keys to be to be created. #1185 + ### Fixed - Fix nightly release build failure issue. #1195 diff --git a/internal/app/wwctl/configure/ssh/main.go b/internal/app/wwctl/configure/ssh/main.go index b88e925e..e2db9aba 100644 --- a/internal/app/wwctl/configure/ssh/main.go +++ b/internal/app/wwctl/configure/ssh/main.go @@ -6,5 +6,5 @@ import ( ) func CobraRunE(cmd *cobra.Command, args []string) error { - return configure.SSH() + return configure.SSH(keyTypes...) } diff --git a/internal/app/wwctl/configure/ssh/root.go b/internal/app/wwctl/configure/ssh/root.go index 6c41d68a..cd08db39 100644 --- a/internal/app/wwctl/configure/ssh/root.go +++ b/internal/app/wwctl/configure/ssh/root.go @@ -12,6 +12,7 @@ var ( "keys.", RunE: CobraRunE, } + keyTypes []string ) func init() { @@ -19,5 +20,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") return baseCmd } diff --git a/internal/pkg/configure/ssh.go b/internal/pkg/configure/ssh.go index 81e04449..16b3c2d5 100644 --- a/internal/pkg/configure/ssh.go +++ b/internal/pkg/configure/ssh.go @@ -11,7 +11,11 @@ import ( "github.com/warewulf/warewulf/internal/pkg/wwlog" ) -func SSH() error { +/* +Create password less ssh keys in the home of the user who its +calling this function. (root in our case) +*/ +func SSH(keyTypes ...string) error { if os.Getuid() == 0 { fmt.Printf("Updating system keys\n") conf := warewulfconf.Get() @@ -23,7 +27,7 @@ func SSH() error { os.Exit(1) } - for _, k := range [4]string{"rsa", "dsa", "ecdsa", "ed25519"} { + for _, k := range keyTypes { keytype := "ssh_host_" + k + "_key" if !util.IsFile(path.Join(wwkeydir, keytype)) { fmt.Printf("Setting up key: %s\n", keytype)