{"record":{"id":"275c65b686a2e3e4","repo":"kovidgoyal/kitty","slug":"password-usage-requested-but-kitty-public-key-envi","errorCode":null,"errorMessage":"Password usage requested but KITTY_PUBLIC_KEY environment variable is not available","messagePattern":"Password usage requested but KITTY_PUBLIC_KEY environment variable is not available","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"kitty/remote_control.py","lineNumber":525,"sourceCode":"        else:\n            try:\n                with open(resolve_custom_file(opts.password_file)) as f:\n                    ans = f.read().rstrip()\n            except OSError:\n                pass\n    if not ans and opts.password_env:\n        ans = os.environ.get(opts.password_env, '')\n    if not ans and opts.use_password == 'always':\n        raise SystemExit('No password was found')\n    if ans and len(ans) > 1024:\n        raise SystemExit('Specified password is too long')\n    return ans\n\n\ndef get_pubkey() -> tuple[str, bytes]:\n    raw = os.environ.get('KITTY_PUBLIC_KEY', '')\n    if not raw:\n        raise SystemExit('Password usage requested but KITTY_PUBLIC_KEY environment variable is not available')\n    version, pubkey = raw.split(':', 1)\n    if version != RC_ENCRYPTION_PROTOCOL_VERSION:\n        raise SystemExit('KITTY_PUBLIC_KEY has unknown version, if you are running on a remote system, update kitty on this system')\n    from base64 import b85decode\n\n    return version, b85decode(pubkey)\n","sourceCodeStart":507,"sourceCodeEnd":532,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/kitty/remote_control.py#L507-L532","documentation":"Encrypted remote control requires kitty's public key exported as KITTY_PUBLIC_KEY (set by kitty when launching a kitten so it can decrypt). If empty, SystemExit is raised.","triggerScenarios":"Invoking remote-control with password/encryption from a process where KITTY_PUBLIC_KEY is not in the environment — e.g. a shell script run outside kitten, or over SSH where the variable was not forwarded.","commonSituations":"Running @ commands via ssh without SendEnv/forwarding, or from cron/scripts where the env var is missing.","solutions":["Run the command via kitten (which kitty launches with KITTY_PUBLIC_KEY set)","Over SSH, forward the variable or source it: export KITTY_PUBLIC_KEY=$(kitten @get-public-key 2>/dev/null || echo \"$KITTY_PUBLIC_KEY\")","Avoid --use-password on the remote side if env cannot be provisioned"],"exampleFix":"# ssh config host block\nSendEnv KITTY_PUBLIC_KEY\n# sshd: AcceptEnv KITTY_PUBLIC_KEY","handlingStrategy":"validation","validationCode":"import os\nassert os.environ.get('KITTY_PUBLIC_KEY'), 'run this via kitten or forward KITTY_PUBLIC_KEY'","typeGuard":"def has_pubkey_env() -> bool: return bool(os.environ.get('KITTY_PUBLIC_KEY'))","tryCatchPattern":null,"preventionTips":["Run @ commands via kitten so kitty sets the env","Configure SendEnv/AcceptEnv KITTY_PUBLIC_KEY for SSH"],"tags":["kitty","remote-control","env-var"],"backgroundTag":"missing-env-var","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}