{"record":{"id":"d7576684309e79d2","repo":"ipfs/kubo","slug":"cannot-export-key-with-name-self","errorCode":null,"errorMessage":"cannot export key with name 'self'","messagePattern":"cannot export key with name 'self'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/keystore.go","lineNumber":195,"sourceCode":"elsewhere. For example, using openssl to get a PEM with public key:\n\n  $ ipfs key export testkey --format=pem-pkcs8-cleartext -o privkey.pem\n  $ openssl pkey -in privkey.pem -pubout > pubkey.pem\n`,\n\t},\n\tArguments: []cmds.Argument{\n\t\tcmds.StringArg(\"name\", true, false, \"name of key to export\").EnableStdin(),\n\t},\n\tOptions: []cmds.Option{\n\t\tcmds.StringOption(outputOptionName, \"o\", \"The path where the output should be stored.\"),\n\t\tcmds.StringOption(keyFormatOptionName, \"f\", \"The format of the exported private key, libp2p-protobuf-cleartext or pem-pkcs8-cleartext.\").WithDefault(keyFormatLibp2pCleartextOption),\n\t},\n\tNoRemote: true,\n\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\tname := req.Arguments[0]\n\n\t\tif name == \"self\" {\n\t\t\treturn fmt.Errorf(\"cannot export key with name 'self'\")\n\t\t}\n\n\t\tcfgRoot, err := cmdenv.GetConfigRoot(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Check repo version, and error out if not matching\n\t\tver, err := migrations.RepoVersion(cfgRoot)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif ver != fsrepo.RepoVersion {\n\t\t\treturn fmt.Errorf(\"key export expects repo version (%d) but found (%d)\", fsrepo.RepoVersion, ver)\n\t\t}\n\n\t\t// Export is read-only: safe to read it without acquiring repo lock\n\t\t// (this makes export work when ipfs daemon is already running)","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/keystore.go#L177-L213","documentation":"Reserved-name guard in `ipfs key export`: the requested export name is 'self', the node's own private identity key. Exporting it would leak the node's primary identity private key to a file, so the command hard-refuses the operation before reading the keystore.","triggerScenarios":"Thrown at core/commands/keystore.go:195 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Export only user-created keys by name, e.g. ipfs key export mykey","Back up the full repo (including the identity key) instead if you truly need the self key","Generate a separate key with ipfs key gen and export that one"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}