kovidgoyal/kitty · error · SystemExit

Specified password is too long

Error message

Specified password is too long

What it means

Remote-control passwords are capped at 1024 bytes; a longer password causes SystemExit 'Specified password is too long'.

Source

Thrown at kitty/remote_control.py:518

                try:
                    tty_fd = os.open(os.ctermid(), os.O_RDONLY | os.O_CLOEXEC)
                except OSError:
                    pass
                else:
                    with open(tty_fd, closefd=True):
                        os.dup2(tty_fd, sys.stdin.fileno())
        else:
            try:
                with open(resolve_custom_file(opts.password_file)) as f:
                    ans = f.read().rstrip()
            except OSError:
                pass
    if not ans and opts.password_env:
        ans = os.environ.get(opts.password_env, '')
    if not ans and opts.use_password == 'always':
        raise SystemExit('No password was found')
    if ans and len(ans) > 1024:
        raise SystemExit('Specified password is too long')
    return ans


def get_pubkey() -> tuple[str, bytes]:
    raw = os.environ.get('KITTY_PUBLIC_KEY', '')
    if not raw:
        raise SystemExit('Password usage requested but KITTY_PUBLIC_KEY environment variable is not available')
    version, pubkey = raw.split(':', 1)
    if version != RC_ENCRYPTION_PROTOCOL_VERSION:
        raise SystemExit('KITTY_PUBLIC_KEY has unknown version, if you are running on a remote system, update kitty on this system')
    from base64 import b85decode

    return version, b85decode(pubkey)

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Use a password of 1024 bytes or fewer
  2. If a long secret is needed, use public-key encryption (KITTY_PUBLIC_KEY) instead
Defensive patterns

Strategy: validation

Validate before calling

assert 0 < len(password) <= 1024

Type guard

def password_ok(p: str) -> bool: return 0 < len(p) <= 1024

Prevention

When it happens

Trigger: Supplying a password longer than 1024 characters via env var or file with password usage enabled.

Common situations: Pasting a key/token instead of a short password.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/d920bcf4f64bb944. Report an issue: GitHub.