Don't use strings.Replace
This commit is contained in:
parent
77ecd0a147
commit
1bae759d3e
1 changed files with 4 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue