From 657104bf912222cd747fca76d1fdfc6c16b7587e Mon Sep 17 00:00:00 2001 From: lmika Date: Tue, 16 Jun 2026 21:35:31 +0000 Subject: [PATCH] Made the key filename ECDSA --- services.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/services.go b/services.go index 56abaa8..cb2ea0a 100644 --- a/services.go +++ b/services.go @@ -12,10 +12,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 { @@ -25,7 +26,7 @@ func (s *Services) AddPrivateKey() error { return err } - if err := writeFile(`${HOME}/.ssh/id_rsa`, s.cfg.PrivateKey, 0400); err != nil { + if err := writeFile(`${HOME}/.ssh/` + s.keyFileName, s.cfg.PrivateKey, 0400); err != nil { return err } @@ -39,9 +40,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 } @@ -115,8 +118,7 @@ func runCmdExpectingOutput(cmd ...string) (string, error) { func writeFile(path string, content string, mode os.FileMode) error { fullPath := os.ExpandEnv(path) - log.Printf(" .. [file] %v (%v bytes)", fullPath, len(content)) - log.Printf(" .. [file] %v", content) + log.Printf(" .. [file] %v (%v bytes)", fullPath, len(content)) return os.WriteFile(fullPath, []byte(content), mode) } @@ -129,6 +131,6 @@ Host * Host {{.Cfg.HostName}} HostName {{.Cfg.HostName}} User dokku - IdentityFile {{.Home}}/.ssh/id_rsa + IdentityFile {{.Home}}/.ssh/{{.KeyFileName}} `)) )