{"record":{"id":"e35f82c77ad6c213","repo":"kubernetes/kops","slug":"error-deleting-ssh-public-key-v","errorCode":null,"errorMessage":"error deleting SSH public key: %v","messagePattern":"error deleting SSH public key: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/delete_sshpublickey.go","lineNumber":81,"sourceCode":"\nfunc RunDeleteSSHPublicKey(ctx context.Context, f *util.Factory, out io.Writer, options *DeleteSSHPublicKeyOptions) error {\n\tclientset, err := f.KopsClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcluster, err := GetCluster(ctx, f, options.ClusterName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsshCredentialStore, err := clientset.SSHCredentialStore(cluster)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := sshCredentialStore.DeleteSSHCredential(); err != nil {\n\t\treturn fmt.Errorf(\"error deleting SSH public key: %v\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":63,"sourceCodeEnd":86,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/delete_sshpublickey.go#L63-L86","documentation":"RunDeleteSSHPublicKey obtains the cluster's SSHCredentialStore and calls DeleteSSHCredential, which removes the cluster's SSH public key entry. Any error from the store is wrapped as \"error deleting SSH public key: %v\". Note it deletes the whole SSH credential, not a key by name.","triggerScenarios":"sshCredentialStore.DeleteSSHCredential() fails: no SSH credential exists for the cluster, state store is unreachable, or permissions prevent writing the deletion.","commonSituations":"Running `kops delete sshpublickey` on a cluster that has no SSH public key published; state store credential/permission issues; wrong --name pointing to a cluster without keys.","solutions":["Check the wrapped %v message: not-found means no key to delete, so nothing to do","Verify the key exists: kops get sshpublickey --name <cluster>","Fix state store access/permissions, then retry the delete"],"exampleFix":"// before (blind delete)\nkops delete sshpublickey --name mycluster.k8s.local --yes\n// after (verify first)\nkops get sshpublickey --name mycluster.k8s.local\nkops delete sshpublickey --name mycluster.k8s.local --yes","handlingStrategy":"try-catch","validationCode":"kops get sshpublickey --name mycluster.k8s.local  # confirm a key exists","typeGuard":null,"tryCatchPattern":"err := RunDeleteSSHPublicKey(ctx, f, out, opts)\nif err != nil && strings.Contains(err.Error(), \"error deleting SSH public key\") {\n    // not-found means nothing to delete; other causes need state store fixes\n    log.Printf(\"ssh public key delete failed: %v\", err)\n}","preventionTips":["Verify a key exists with kops get sshpublickey before deleting","Remember this deletes the cluster's whole SSH credential, not one key by name","Check state store credentials and write permissions before the delete"],"tags":["cli","ssh","state-store"],"backgroundTag":"secret-delete-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}