Don't use strings.Replace

This commit is contained in:
Caleb Brose 2022-06-29 11:10:50 -05:00
parent 77ecd0a147
commit 1bae759d3e

View file

@ -273,13 +273,15 @@ func checkAndUpdateOldKeyPair(sshContext ssh.Context) *ssh.KeyPair {
// Both old public and private keys exist, rename them to the new name
publicKeyNew := strings.Replace(publicKey, automaticPrivateKeyNameOld, automaticPrivateKeyName, -1)
sshDir := filepath.Dir(publicKey)
publicKeyNew := filepath.Join(sshDir, automaticPrivateKeyName+".pub")
err = os.Rename(publicKey, publicKeyNew)
if err != nil {
return nil
}
privateKeyNew := strings.Replace(privateKey, automaticPrivateKeyNameOld, automaticPrivateKeyName, -1)
privateKeyNew := filepath.Join(sshDir, automaticPrivateKeyName)
err = os.Rename(privateKey, privateKeyNew)
if err != nil {
return nil