Made the key filename ECDSA
This commit is contained in:
parent
2ad19740fc
commit
657104bf91
1 changed files with 7 additions and 5 deletions
10
services.go
10
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
|
||||
}
|
||||
|
|
@ -116,7 +119,6 @@ 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)
|
||||
|
||||
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}}
|
||||
`))
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue