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 { type Services struct {
cfg config cfg config
keyFileName string
} }
func NewServices(cfg config) *Services { func NewServices(cfg config) *Services {
return &Services{cfg: cfg} return &Services{cfg: cfg, keyFileName: "id_ecdsa"}
} }
func (s *Services) AddPrivateKey() error { func (s *Services) AddPrivateKey() error {
@ -26,7 +27,8 @@ func (s *Services) AddPrivateKey() error {
return err 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 return err
} }
@ -40,9 +42,11 @@ func (s *Services) ConfigureSSH() error {
if err := sshConfigTemplate.Execute(&bfr, struct { if err := sshConfigTemplate.Execute(&bfr, struct {
Cfg config Cfg config
Home string Home string
KeyFileName string
}{ }{
Cfg: s.cfg, Cfg: s.cfg,
Home: os.Getenv("HOME"), Home: os.Getenv("HOME"),
KeyFileName: s.keyFileName,
}); err != nil { }); err != nil {
return err return err
} }
@ -128,6 +132,6 @@ Host *
Host {{.Cfg.HostName}} Host {{.Cfg.HostName}}
HostName {{.Cfg.HostName}} HostName {{.Cfg.HostName}}
User dokku User dokku
IdentityFile {{.Home}}/.ssh/id_rsa IdentityFile {{.Home}}/.ssh/{{.KeyFileName}}
`)) `))
) )