[BUG] CLI login fails to allow pasting the code from the browser when terminal paste bracketing is enabled

Resolved 💬 35 comments Opened Apr 13, 2026 by MattMcmullanQumulo Closed Apr 14, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

CLI login fails to allow pasting the code from the browser when terminal paste bracketing is enabled.

What Should Happen?

You should be able to paste the login code into the login prompt in the CLI.

Error Messages/Logs

Steps to Reproduce

  • Install claude code on a linux machine
  • Open a command window using a terminal that has paste bracketing enabled by default. iterm2 ships with this enabled by default, as do many others. I experienced this bug first over ssh with the iterm2 mac client ssh'd into linux.
  • Launch claude code
  • Optional: Try pasting any text into the main chat window and observe that this works as expected
  • Run the /login command
  • Log in using subscription
  • Click the link and follow directions
  • Paste login code back into the terminal. Observe that this fails to work.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.105 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

iTerm2

Additional Information

I've used the same terminal setup for a long time. The last time I needed to login to Claude code, this exact workflow was functional.

Mitigation steps: Disable terminal paste bracketing in the terminal's settings.

View original on GitHub ↗

35 Comments

omenking · 3 months ago

I am running WSL2 and I cannot paste my code in any longer and its the only way to login via WSL2.

<img width="697" height="308" alt="Image" src="https://github.com/user-attachments/assets/4cd827dd-718a-4a46-a920-22e2d8105229" />

Turning of bracketed paste does not solve the problem on WSL2

bind 'set enable-bracketed-paste off'

4141done · 3 months ago

Affected by this as well using devcontainer in zed and vscode on MacOS

adriand · 3 months ago

Also affected by this, v2.1.105, I'm shelled into my Mac Mini and cannot paste the code. However, I can type into the field where the code goes. It's just that Cmd-V does not work. This is new, has never happened.

mickaeldanslenowhere · 3 months ago

same same

naynayll2 · 3 months ago

Installed for the first time and seeing this as well
v2.1.105 on linux mint

irvinghu07 · 3 months ago

Same issue

troglodyne · 3 months ago

Hit this earlier tonight. Sadly, going back to 'stable' doesn't work for me via the 'install' opt, it results in a successful paste & login, followed by 401 on actually trying to do anything, leading you back to login.

humphrey · 3 months ago

Same issue for me on MacOS using iTerm2.

I was able to work around it by going Settings > Profiles > Default > Terminal > [uncheck] Terminal may enable paste bracketing

duccanh-he181774 · 3 months ago

Got same problem!
Can't paste cde

Linux instance-20260326-042220 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64 GNU/Linux

mischadiehm · 3 months ago

Me too on debian whats going?

briannaj · 3 months ago

Also affected on this

DocksDocks · 3 months ago

Also affected on this

7011yamazakyuuta-star · 3 months ago

Same issue on Google Colab's built-in terminal with v2.1.105. Paste works everywhere else but not at the auth code prompt.

Davie521 · 3 months ago

same issue when ssh into remote linux machine

sgraphics · 3 months ago

Hitting same issue (Windows Terminal into SSH), whats the fix?

fgeorjon · 3 months ago

I have been facing the issue as well for the last few hours ...

mansoorahmadhh · 3 months ago

Facing also same issue under Linux Terminal since today

Issue is also in Claude Code v2.1.107

rj2w · 3 months ago

Hit the same issue. Reverting back to 'stable' seems to work for me, and it's just now that I realized 'stable' isn't the default!

mansoorahmadhh · 3 months ago

Found Workaround:

Workaround – Disable paste bracketing
iTerm2: Preferences → Profiles → Terminal → disable "Enable bracketed paste mode"

<img width="1026" height="667" alt="Image" src="https://github.com/user-attachments/assets/74e83074-98fd-4164-a04e-97cfbc5855a6" />

But dont forget to reactivate it again after auth...

jelmerdehen · 3 months ago

My workaround was using xdotool to "type" the keys into the terminal:

sleep 5 && xdotool type --delay 100 "$(xclip -selection clipboard -o)"

Then I asked Claude to make a cross-platform script to do just that:

#!/usr/bin/env bash
# ==============================================================
# claude-paste.sh
# Sends the CURRENT clipboard content to the *focused* window
# (one keystroke at a time with 100ms delay) — perfect for
# Claude Code /login when normal paste is broken.
#
# Supported environments (auto-detected):
#   - macOS    (pbpaste + osascript)
#   - Windows  (powershell clip via Git Bash / MSYS2 / WSL)
#   - Wayland  (wtype + wl-paste)
#   - X11/Xorg (xdotool + xclip or xsel)
#   - tmux     (bracketed-paste via tmux send-keys)
# ==============================================================

set -euo pipefail

DELAY=100  # milliseconds between keystrokes

# --- Detect display server / environment ---

detect_backend() {
    case "$(uname -s)" in
        Darwin)
            echo "macos"
            return
            ;;
        CYGWIN*|MINGW*|MSYS*)
            echo "windows"
            return
            ;;
    esac

    # WSL detection (Linux kernel but Windows host)
    if [[ -f /proc/version ]] && grep -qi microsoft /proc/version 2>/dev/null; then
        echo "windows"
    elif [[ "${XDG_SESSION_TYPE:-}" == "wayland" ]] || [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
        echo "wayland"
    elif [[ -n "${DISPLAY:-}" ]]; then
        echo "x11"
    elif [[ -n "${TMUX:-}" ]]; then
        echo "tmux"
    else
        echo "unknown"
    fi
}

BACKEND=$(detect_backend)

# --- Read clipboard per backend ---

read_clipboard() {
    case "$BACKEND" in
        macos)
            pbpaste 2>/dev/null
            ;;
        windows)
            if command -v powershell.exe >/dev/null; then
                powershell.exe -NoProfile -Command "Get-Clipboard" 2>/dev/null | tr -d '\r'
            elif command -v powershell >/dev/null; then
                powershell -NoProfile -Command "Get-Clipboard" 2>/dev/null | tr -d '\r'
            else
                echo "Cannot find powershell.exe to read clipboard." >&2
                exit 1
            fi
            ;;
        wayland)
            if ! command -v wl-paste >/dev/null; then
                echo "Missing wl-paste. Install wl-clipboard:" >&2
                echo "  Debian/Ubuntu: sudo apt install wl-clipboard" >&2
                echo "  Fedora:        sudo dnf install wl-clipboard" >&2
                echo "  Arch:          sudo pacman -S wl-clipboard" >&2
                exit 1
            fi
            wl-paste --no-newline 2>/dev/null
            ;;
        x11)
            if command -v xclip >/dev/null; then
                xclip -selection clipboard -o 2>/dev/null
            elif command -v xsel >/dev/null; then
                xsel --clipboard --output 2>/dev/null
            else
                echo "Missing xclip or xsel. Install one:" >&2
                echo "  Debian/Ubuntu: sudo apt install xclip" >&2
                echo "  Fedora:        sudo dnf install xclip" >&2
                echo "  Arch:          sudo pacman -S xclip" >&2
                exit 1
            fi
            ;;
        tmux)
            tmux show-buffer 2>/dev/null
            ;;
        *)
            echo "Could not detect display server (no WAYLAND_DISPLAY, DISPLAY, or TMUX)." >&2
            echo "Run this from a graphical session or inside tmux." >&2
            exit 1
            ;;
    esac
}

# --- Type/send text per backend ---

send_text() {
    local text="$1"
    case "$BACKEND" in
        macos)
            # Use osascript to type keystrokes into the frontmost application.
            # We type char-by-char with a delay for reliability.
            local delay_sec
            delay_sec=$(awk "BEGIN {printf \"%.3f\", ${DELAY}/1000}")
            osascript \
                -e "on run argv" \
                -e "  set theText to item 1 of argv" \
                -e "  tell application \"System Events\"" \
                -e "    repeat with i from 1 to count of theText" \
                -e "      keystroke (character i of theText)" \
                -e "      delay ${delay_sec}" \
                -e "    end repeat" \
                -e "  end tell" \
                -e "end run" \
                -- "$text" 2>/dev/null
            ;;
        windows)
            # Use PowerShell SendKeys to type into the active window
            local ps_exe="powershell.exe"
            command -v powershell.exe >/dev/null || ps_exe="powershell"
            # Escape text for PowerShell: double any single-quotes
            local escaped="${text//\'/\'\'}"
            "$ps_exe" -NoProfile -Command "
                Add-Type -AssemblyName System.Windows.Forms
                \$text = '${escaped}'
                # SendKeys special chars: +^%~(){}[] must be escaped with braces
                \$special = '[+^%~(){}[\]]'
                foreach (\$char in \$text.ToCharArray()) {
                    \$s = \$char.ToString()
                    if (\$s -match \$special) { \$s = '{{0}}' -f \$s }
                    [System.Windows.Forms.SendKeys]::SendWait(\$s)
                    Start-Sleep -Milliseconds ${DELAY}
                }
            " 2>/dev/null
            ;;
        wayland)
            if ! command -v wtype >/dev/null; then
                echo "Missing wtype. Install it:" >&2
                echo "  Debian/Ubuntu: sudo apt install wtype" >&2
                echo "  Fedora:        sudo dnf install wtype" >&2
                echo "  Arch:          sudo pacman -S wtype" >&2
                exit 1
            fi
            wtype -d "$DELAY" "$text"
            ;;
        x11)
            if ! command -v xdotool >/dev/null; then
                echo "Missing xdotool. Install it:" >&2
                echo "  Debian/Ubuntu: sudo apt install xdotool" >&2
                echo "  Fedora:        sudo dnf install xdotool" >&2
                echo "  Arch:          sudo pacman -S xdotool" >&2
                exit 1
            fi
            xdotool type --delay "$DELAY" -- "$text"
            ;;
        tmux)
            # Use bracketed-paste mode so the terminal treats it as pasted text
            tmux send-keys -l "$text"
            ;;
    esac
}

# --- Main ---

CLIPBOARD=$(read_clipboard)

if [[ -z "$CLIPBOARD" ]]; then
    echo "Clipboard is empty — nothing to send." >&2
    exit 1
fi

echo "Backend:  $BACKEND"
echo "Length:   ${#CLIPBOARD} characters"
echo "Sending clipboard to focused window in 3 seconds (${DELAY}ms delay between keys)..."
sleep 3

send_text "$CLIPBOARD"

echo "Done!"
IsaacClarke2 · 3 months ago

Confirming this issue with Termius (SSH client) connecting to a remote Ubuntu server.

Environment:

  • Client: Termius (desktop)
  • Server: Ubuntu (root, remote VPS)
  • Claude Code: latest version
  • Auth method: OAuth (Max subscription)

Problem:
Pasting the OAuth code into the "Paste code here" prompt does nothing. Ctrl+V, Ctrl+Shift+V, right-click paste — none of them work. The code simply doesn't appear in the input field. Previously this worked fine with the same setup.

What didn't work:

  • printf '\e[?2004l' before launching claude (bracket paste disable escape sequence) — paste still broken
  • Restarting Termius
  • Restarting Claude Code

What worked — tmux send-keys workaround:

  1. Install tmux on the remote server:
apt install tmux -y
  1. Start a tmux session and launch Claude Code:
tmux
claude
  1. Proceed through /login, select auth method, open the OAuth URL in browser, get the code.
  1. Open a second SSH session to the same server and send the code via tmux:
tmux send-keys -l "YOUR_OAUTH_CODE_HERE"

This bypasses the broken paste entirely by injecting the text directly into the tmux pane as literal keystrokes. After that, hit Enter in the Claude Code session and login completes successfully.

Note: The tmux send-keys -l approach from the cross-platform script shared above also works. The key insight is that tmux's send-keys -l sends text as literal input, avoiding whatever paste bracketing issue is causing the problem in the TUI.

rj2w · 3 months ago

Ooh.. a relatively simple workaround if you have the older versions still installed.

.local/share/claude/versions/2.1.104

Authenticate, that version still worked. Then /exit and run the current claude. If you don't have an old version installed you can probably get one by installing 'stable' and then this should work with no hoopty paste tricks.

aommm · 3 months ago

One workaround that worked for me was to sign in via the Claude Desktop app, and later launch the CLI. (Worked with Enterprise SSO)

panthablack · 3 months ago

Also affected by this. Signing in on an older version workaround worked for me, too. Just make sure to go through the whole onboarding process, then /exit. If you just go through the auth process the next log in will try to take you through it all again.

JonaPlaz · 3 months ago

I have a solution that works for me.

WSL workaround when paste is broken during /login

If you're on WSL, have no browser, and can't paste the token, install wslu so WSL can open your Windows browser for
the OAuth flow:

Run these commands in your WSL terminal:
sudo apt update && sudo apt install -y wslu
echo 'export BROWSER=wslview' >> ~/.bashrc
source ~/.bashrc
claude
/login

(On older Ubuntu: sudo add-apt-repository ppa:wslutilities/wslu first.)

The browser will open automatically and the login will complete automatically. Tested on Windows 11 + WSL2 Ubuntu.

algerkong · 3 months ago
I have a solution that works for me. WSL workaround when paste is broken during /login If you're on WSL, have no browser, and can't paste the token, install wslu so WSL can open your Windows browser for the OAuth flow: Run these commands in your WSL terminal: sudo apt update && sudo apt install -y wslu echo 'export BROWSER=wslview' >> ~/.bashrc source ~/.bashrc claude /login (On older Ubuntu: sudo add-apt-repository ppa:wslutilities/wslu first.) The browser will open automatically and the login will complete automatically. Tested on Windows 11 + WSL2 Ubuntu.

This solved my WSL issue, thanks!

leafnet-t-miyasawa · 3 months ago

2.1.107
2.1.105
The same phenomenon occurred, but

When I reverted to the version using npm install -g @anthropic-ai/claude-code@2.1.104

Ctrl + V
worked.

dunnock · 3 months ago
tmux send-keys -l "YOUR_OAUTH_CODE_HERE" This bypasses the broken paste entirely by injecting the text directly into the tmux pane as literal keystrokes. After that, hit Enter in the Claude Code session and login completes successfully. Note: The tmux send-keys -l approach from the cross-platform script shared above also works. The key insight is that tmux's send-keys -l sends text as literal input, avoiding whatever paste bracketing issue is causing the problem in the TUI.

could also use ^b+: in tmux console where claude code is waiting for the token and type send-keys "<token>" in there . no need to juggle with sessions

mazenalhomsie · 3 months ago
sgraphics · 3 months ago
Found a clean fix for this — skip OAuth entirely and use an API key directly. Wrote up the full story here: https://www.linkedin.com/posts/mazenalhomsie_claudecode-anthropic-windows-activity-7449839647951622144-G5PS?utm_source=social_share_send&utm_medium=member_desktop_web&rcm=ACoAABNVF0kBrx6HcZHpDEaiIi3WDLOn2V-Xp_o

??? then you are not using your subscription, but paying extra for each call

johnjhughes · 3 months ago

I’m seeing the same issue on Claude Code v2.1.107.

In my case:

  • Client terminals: WezTerm and macOS Terminal
  • Remote usage: over SSH to a Linux machine
  • Session types tested: plain/bare SSH, inside Zellij, and inside tmux
  • Result: same behavior in all of the above

What’s notable is that paste works everywhere else:

  • other apps over the same SSH connection paste normally
  • Claude Code’s normal input box also accepts pasted text normally

The only place paste fails is the login flow at the Paste code here if prompted > prompt. The pasted auth code simply does not appear / is not accepted.

Because normal paste works in the same terminal session and even in Claude Code itself, this seems specific to the login prompt rather than SSH, the terminal emulator, or the multiplexer. My guess is that it may be related to whatever special handling is used for hidden/masked auth-code input after paste.

Workaround that succeeded for me:

  1. Open Claude Code inside a tmux session
  2. From another shell on the same machine, send the auth code as literal keystrokes instead of pasting it:
tmux send-keys -t <session>:<window>.<pane> -l 'YOUR_OAUTH_CODE_HERE'
tmux send-keys -t <session>:<window>.<pane> Enter

That worked immediately, which also suggests the problem is in paste handling at the login prompt rather than the auth code itself.

kscheyer · 3 months ago

When I revert to .104 or older versions, I don't have the /login command. Anyone else have the same problem?

RizwanSabir · 3 months ago

CLI login fails to allow pasting the code from the browser when terminal paste?? any solution

Ironsail-Philip · 3 months ago

Fixed via tmux send-keys injection — for anyone locked out remotely with no keyboard: start Claude in a tmux session, get the auth URL, open it on another device, then have a remote process inject the auth code directly via tmux send-keys -t <session> "<code>" Enter. Completely bypasses the paste issue.

Also recommend adding these three lines to ~/.tmux.conf:

set -g allow-passthrough on
set -g set-clipboard on
set -s extended-keys on

This lets tmux handle OSC 52 clipboard sequences properly over SSH. Combined with the send-keys injection method, you never need to paste during the login flow at all.

github-actions[bot] · 2 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.