Skip to content

Commit

Permalink
Fix handling dev ssh key
Browse files Browse the repository at this point in the history
  • Loading branch information
Frostman committed Sep 30, 2023
1 parent 4db4d5b commit 6cc248c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion pkg/fab/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,18 @@ func (cfg *Base) Hydrate(preset cnc.Preset) error {
if !slices.Contains(cfg.AuthorizedKeys, val) {
cfg.AuthorizedKeys = append(cfg.AuthorizedKeys, val)
}
if cfg.Dev && !slices.Contains(cfg.AuthorizedKeys, DEV_SSH_KEY) {
cfg.AuthorizedKeys = append(cfg.AuthorizedKeys, DEV_SSH_KEY)
}
}

if preset == PRESET_VLAB {
cfg.Dev = true
}

slog.Warn("Attention! Development mode enabled - this is not secure! Default users and keys will be created.")
if cfg.Dev {
slog.Warn("Attention! Development mode enabled - this is not secure! Default users and keys will be created.")
}

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/fab/ctrl_os_butane.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ passwd:
- name: {{ .username }}
ssh_authorized_keys:
{{ range .authorizedKeys}}
- {{ . }}
- "{{ . }}"
{{ end }}
groups:
- wheel
Expand Down
1 change: 0 additions & 1 deletion pkg/fab/fabric.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func (cfg *Fabric) Build(basedir string, preset cnc.Preset, get cnc.GetComponent
slog.Info("Adding dev users", "users", users)
for idx := range users {
users[idx].SSHKeys = append(users[idx].SSHKeys, BaseConfig(get).AuthorizedKeys...)
users[idx].SSHKeys = append(users[idx].SSHKeys, DEV_SSH_KEY)
slog.Info("Adding dev ssh keys to user", "user", users[idx])
}
}
Expand Down

0 comments on commit 6cc248c

Please sign in to comment.