Skip to content

Commit

Permalink
Don't reuse previous deploy keys
Browse files Browse the repository at this point in the history
Also don't ask people to ssh-add them into their keychain as they can interfere with other git creds
  • Loading branch information
michaeljguarino committed May 23, 2022
1 parent 494b2da commit 2996066
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions pkg/scm/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ type keys struct {
}

func generateKeys() (pub string, priv string, err error) {
pub, priv, found := readKeys()
if found {
return
}

pubKey, privKey, err := ed25519.GenerateKey(rand.Reader)
if err != nil {
return
Expand All @@ -44,30 +39,6 @@ func generateKeys() (pub string, priv string, err error) {
return
}

func readKeys() (pub string, priv string, found bool) {
keys, err := keyFiles()
if err != nil {
return
}

if !utils.Exists(keys.pub) || !utils.Exists(keys.priv) {
return
}

pub, err = utils.ReadFile(keys.pub)
if err != nil {
return
}

priv, err = utils.ReadFile(keys.priv)
if err != nil {
return
}

found = true
return
}

func saveKeys(pub, priv string) error {
if !utils.Confirm("Would you like to save the keys to ~/.ssh?") {
return nil
Expand All @@ -90,12 +61,7 @@ func saveKeys(pub, priv string) error {
return err
}

if sshadd, _ := utils.Which("ssh-add"); sshadd && utils.Confirm("would you like to add this key to your ssh agent (ignore if your git ssh is set up)?") {
return utils.Exec("ssh-add", keys.priv)
}

utils.Highlight("It looks like ssh isn't configured locally, once you have it set up, you can run `ssh-add ~/.ssh/id_plural` to add the key to your agent")
return err
return nil
}

func keyFiles() (keys keys, err error) {
Expand Down

0 comments on commit 2996066

Please sign in to comment.