Merge remote-tracking branch 'origin/main'

This commit is contained in:
Leon Mika 2026-08-05 21:07:04 +10:00
commit ed70faa854

View file

@ -13,10 +13,11 @@ import (
type Services struct {
cfg config
keyFileName string
}
func NewServices(cfg config) *Services {
return &Services{cfg: cfg}
return &Services{cfg: cfg, keyFileName: "id_ecdsa"}
}
func (s *Services) AddPrivateKey() error {
@ -26,7 +27,8 @@ func (s *Services) AddPrivateKey() error {
return err
}
if err := writeFile(`${HOME}/.ssh/id_rsa`, s.cfg.PrivateKey, 0400); err != nil {
privateKey := strings.TrimSpace(s.cfg.PrivateKey) + "\n"
if err := writeFile(`${HOME}/.ssh/` + s.keyFileName, privateKey, 0400); err != nil {
return err
}
@ -40,9 +42,11 @@ func (s *Services) ConfigureSSH() error {
if err := sshConfigTemplate.Execute(&bfr, struct {
Cfg config
Home string
KeyFileName string
}{
Cfg: s.cfg,
Home: os.Getenv("HOME"),
KeyFileName: s.keyFileName,
}); err != nil {
return err
}
@ -128,6 +132,6 @@ Host *
Host {{.Cfg.HostName}}
HostName {{.Cfg.HostName}}
User dokku
IdentityFile {{.Home}}/.ssh/id_rsa
IdentityFile {{.Home}}/.ssh/{{.KeyFileName}}
`))
)