Skip to content

Commit

Permalink
Rename public key first for edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbrose committed Jun 29, 2022
1 parent 2ac379f commit 77ecd0a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/cmd/codespace/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,14 @@ func checkAndUpdateOldKeyPair(sshContext ssh.Context) *ssh.KeyPair {

// Both old public and private keys exist, rename them to the new name

privateKeyNew := strings.Replace(privateKey, automaticPrivateKeyNameOld, automaticPrivateKeyName, -1)
err = os.Rename(privateKey, privateKeyNew)
publicKeyNew := strings.Replace(publicKey, automaticPrivateKeyNameOld, automaticPrivateKeyName, -1)
err = os.Rename(publicKey, publicKeyNew)
if err != nil {
return nil
}

publicKeyNew := strings.Replace(publicKey, automaticPrivateKeyNameOld, automaticPrivateKeyName, -1)
err = os.Rename(publicKey, publicKeyNew)
privateKeyNew := strings.Replace(privateKey, automaticPrivateKeyNameOld, automaticPrivateKeyName, -1)
err = os.Rename(privateKey, privateKeyNew)
if err != nil {
return nil
}
Expand Down

0 comments on commit 77ecd0a

Please sign in to comment.