tsh: Suppress PPK deletion error when file doesn't exist (#14570)

This commit is contained in:
Gus Luxton
2022-07-18 13:34:21 +00:00
committed by GitHub
parent ad512e449f
commit 5da1c91685
+6 -4
View File
@@ -204,15 +204,17 @@ func (fs *FSLocalKeyStore) DeleteKey(idx KeyIndex) error {
fs.sshCAsPath(idx),
fs.tlsCertPath(idx),
}
// we also need to delete the extra PuTTY-formatted .ppk file when running on Windows
if runtime.GOOS == constants.WindowsOS {
files = append(files, fs.PPKFilePath(idx))
}
for _, fn := range files {
if err := os.Remove(fn); err != nil {
return trace.ConvertSystemError(err)
}
}
// we also need to delete the extra PuTTY-formatted .ppk file when running on Windows,
// but it may not exist when upgrading from v9 -> v10 and logging into an existing cluster.
// as such, deletion should be best-effort and not generate an error if it fails.
if runtime.GOOS == constants.WindowsOS {
os.Remove(fs.PPKFilePath(idx))
}
// Clear ClusterName to delete the user certs stored for all clusters.
idx.ClusterName = ""