{"record":{"id":"56b9a17da0a30964","repo":"kovidgoyal/kitty","slug":"password-usage-requested-but-kitty-public-key-envi-56b9a1","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":null,"httpStatus":null,"severity":"error","filePath":"tools/cmd/at/main.go","lineNumber":77,"sourceCode":"\tfor i, x := range args {\n\t\tans[i] = escaped_string(x)\n\t}\n\treturn ans\n}\n\nfunc set_payload_string_field(io_data *rc_io_data, field, data string) {\n\tpayload_interface := reflect.ValueOf(&io_data.rc.Payload).Elem()\n\tstruct_in_interface := reflect.New(payload_interface.Elem().Type()).Elem()\n\tstruct_in_interface.Set(payload_interface.Elem()) // copies the payload to struct_in_interface\n\tstruct_in_interface.FieldByName(field).SetString(data)\n\tpayload_interface.Set(struct_in_interface) // copies struct_in_interface back to payload\n}\n\nfunc get_pubkey(encoded_key string) (encryption_version string, pubkey []byte, err error) {\n\tif encoded_key == \"\" {\n\t\tencoded_key = os.Getenv(\"KITTY_PUBLIC_KEY\")\n\t\tif encoded_key == \"\" {\n\t\t\terr = fmt.Errorf(\"Password usage requested but KITTY_PUBLIC_KEY environment variable is not available\")\n\t\t\treturn\n\t\t}\n\t}\n\tencryption_version, encoded_key, found := strings.Cut(encoded_key, \":\")\n\tif !found {\n\t\terr = fmt.Errorf(\"KITTY_PUBLIC_KEY environment variable does not have a : in it\")\n\t\treturn\n\t}\n\tif encryption_version != kitty.RC_ENCRYPTION_PROTOCOL_VERSION {\n\t\terr = fmt.Errorf(\"KITTY_PUBLIC_KEY has unknown version, if you are running on a remote system, update kitty on this system\")\n\t\treturn\n\t}\n\tpubkey = make([]byte, base85.DecodedLen(len(encoded_key)))\n\tn, err := base85.Decode(pubkey, []byte(encoded_key))\n\tif err == nil {\n\t\tpubkey = pubkey[:n]\n\t}\n\treturn","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/tools/cmd/at/main.go#L59-L95","documentation":"kitty @ (remote control CLI) was asked to use password-authenticated remote control, but the KITTY_PUBLIC_KEY environment variable is unset or empty. That variable is how kitty passes its public key to child processes so they can encrypt the password; without it no encrypted channel can be established.","triggerScenarios":"Using --use-password with kitty @ (e.g. password required/always) when KITTY_PUBLIC_KEY was not inherited — typically because the command runs over ssh, from cron, or from a shell started before the variable existed.","commonSituations":"Running kitty @ on a remote host over ssh without forwarding the environment, invoking from systemd/launchd services, or shells whose startup files scrub the environment.","solutions":["Run kitty @ from a process spawned by the kitty terminal itself (it exports KITTY_PUBLIC_KEY)","If remote, echo/forward the value: on the local side read it and export it in the remote session, e.g. ssh host 'KITTY_PUBLIC_KEY=\"$KITTY_PUBLIC_KEY\" kitty @ ls'","Alternatively launch kitty with --execute and env passthrough, or use the remote control socket directly","Update kitty on both ends so the variable is exported"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if os.Getenv(\"KITTY_PUBLIC_KEY\") == \"\" {\n    return errors.New(\"run inside kitty or forward KITTY_PUBLIC_KEY\")\n}","typeGuard":"func hasPublicKey() bool { return os.Getenv(\"KITTY_PUBLIC_KEY\") != \"\" }","tryCatchPattern":"if _, _, err := get_pubkey(\"\"); err != nil { /* fall back to --use-password=never or socket auth */ }","preventionTips":["Run @ commands from shells spawned by kitty","Forward KITTY_PUBLIC_KEY explicitly over ssh"],"tags":["kitty","remote-control","environment-variable","authentication"],"backgroundTag":"missing-env-var","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}