Merge pull request #1708 from anderbubble/ssh-key-default

Re-order SSH key types to make ed25519 default
This commit is contained in:
Xu YANG
2025-02-07 12:07:06 +09:00
committed by GitHub
7 changed files with 23 additions and 12 deletions

View File

@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Simpler permissions in official RPM packages. #1696 - Simpler permissions in official RPM packages. #1696
- Only calculate image chroot size when requested. #1504 - Only calculate image chroot size when requested. #1504
- Create temporary files in overlay directory during `wwctl overlay edit`. #1473 - Create temporary files in overlay directory during `wwctl overlay edit`. #1473
- Re-order SSH key types to make ed25519 default. #981
### Fixed ### Fixed

View File

@@ -33,7 +33,7 @@ image mounts:
readonly: true readonly: true
ssh: ssh:
key types: key types:
- ed25519
- ecdsa
- rsa - rsa
- dsa - dsa
- ecdsa
- ed25519

View File

@@ -1,5 +1,5 @@
package config package config
type SSHConf struct { type SSHConf struct {
KeyTypes []string `yaml:"key types,omitempty" default:"[\"rsa\",\"dsa\",\"ecdsa\",\"ed25519\"]"` KeyTypes []string `yaml:"key types,omitempty" default:"[\"ed25519\",\"ecdsa\",\"rsa\",\"dsa\"]"`
} }

View File

@@ -6,6 +6,7 @@ import (
"path" "path"
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config" warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
"github.com/warewulf/warewulf/internal/pkg/overlay"
"github.com/warewulf/warewulf/internal/pkg/util" "github.com/warewulf/warewulf/internal/pkg/util"
"github.com/warewulf/warewulf/internal/pkg/wwlog" "github.com/warewulf/warewulf/internal/pkg/wwlog"
) )
@@ -18,6 +19,15 @@ func SSH(keyTypes ...string) error {
if os.Getuid() == 0 { if os.Getuid() == 0 {
fmt.Printf("Updating system keys\n") fmt.Printf("Updating system keys\n")
conf := warewulfconf.Get() conf := warewulfconf.Get()
if conf.Warewulf.EnableHostOverlay() {
if err := overlay.BuildHostOverlay(); err != nil {
wwlog.Warn("host overlay could not be built: %s", err)
}
} else {
wwlog.Info("host overlays are disabled")
}
wwkeydir := path.Join(conf.Paths.Sysconfdir, "warewulf/keys") + "/" wwkeydir := path.Join(conf.Paths.Sysconfdir, "warewulf/keys") + "/"
err := os.MkdirAll(path.Join(conf.Paths.Sysconfdir, "warewulf/keys"), 0755) err := os.MkdirAll(path.Join(conf.Paths.Sysconfdir, "warewulf/keys"), 0755)

View File

@@ -109,11 +109,11 @@ data from other structures.
### SSH ### SSH
- Key types: - Key types:
- ed25519
- ecdsa
- rsa - rsa
- dsa - dsa
- ecdsa - First key type: ed25519
- ed25519
- First key type: rsa
## Node ## Node

View File

@@ -313,7 +313,7 @@ Filename: etc/profile.d/ssh_setup.csh
if ( ( $_UID > 500 || $_UID == 0 ) && ( ! -f "$HOME/.ssh/config" && ! -f "$HOME/.ssh/cluster" ) ) then if ( ( $_UID > 500 || $_UID == 0 ) && ( ! -f "$HOME/.ssh/config" && ! -f "$HOME/.ssh/cluster" ) ) then
echo "Configuring SSH for cluster access" echo "Configuring SSH for cluster access"
install -d -m 700 $HOME/.ssh install -d -m 700 $HOME/.ssh
ssh-keygen -t rsa -f $HOME/.ssh/cluster -N '' -C "Warewulf Cluster key" >& /dev/null ssh-keygen -t ed25519 -f $HOME/.ssh/cluster -N '' -C "Warewulf Cluster key" >& /dev/null
cat $HOME/.ssh/cluster.pub >>! $HOME/.ssh/authorized_keys cat $HOME/.ssh/cluster.pub >>! $HOME/.ssh/authorized_keys
chmod 0600 $HOME/.ssh/authorized_keys chmod 0600 $HOME/.ssh/authorized_keys
@@ -347,7 +347,7 @@ Filename: etc/profile.d/ssh_setup.sh
if [ $_UID -ge 500 -o $_UID -eq 0 ] && [ ! -f "$HOME/.ssh/config" -a ! -f "$HOME/.ssh/cluster" ]; then if [ $_UID -ge 500 -o $_UID -eq 0 ] && [ ! -f "$HOME/.ssh/config" -a ! -f "$HOME/.ssh/cluster" ]; then
echo "Configuring SSH for cluster access" echo "Configuring SSH for cluster access"
install -d -m 700 $HOME/.ssh install -d -m 700 $HOME/.ssh
ssh-keygen -t rsa -f $HOME/.ssh/cluster -N '' -C "Warewulf Cluster key" > /dev/null 2>&1 ssh-keygen -t ed25519 -f $HOME/.ssh/cluster -N '' -C "Warewulf Cluster key" > /dev/null 2>&1
cat $HOME/.ssh/cluster.pub >> $HOME/.ssh/authorized_keys cat $HOME/.ssh/cluster.pub >> $HOME/.ssh/authorized_keys
chmod 0600 $HOME/.ssh/authorized_keys chmod 0600 $HOME/.ssh/authorized_keys

View File

@@ -46,10 +46,10 @@ Warewulf (4.6.0):
readonly: true readonly: true
ssh: ssh:
key types: key types:
- ed25519
- ecdsa
- rsa - rsa
- dsa - dsa
- ecdsa
- ed25519
wwclient: wwclient:
port: 0 port: 0
@@ -165,10 +165,10 @@ SSH key types to generate during ``wwctl configure ssh`` may be overridden using
ssh: ssh:
key types: key types:
- ed25519
- ecdsa
- rsa - rsa
- dsa - dsa
- ecdsa
- ed25519
Warewulf will generate host keys for each listed key type. Warewulf will generate host keys for each listed key type.
The first listed key type is used to generate authentication ssh keys. The first listed key type is used to generate authentication ssh keys.