How to fix WSL in VS Code not allowing login password in terminal of VS code?

Jonathan Margalit 0 Reputation points
2026-11-20T22:11:07.18+00:00

I have a PC working on Windows 11, and I have installed WSL 2 and need to work on a project via VS code.
I need to make some installations which need password authentication.

When I plug in the password in the windows terminal (which is logged into the WSL2 linux distro) eveything works just fine.
when i try the SAME COMMAND via the VS code terminal (which is also connected to the same WSL2 distro) i get an error in the password authentication phase with "Sorry, try again" error.

I dont understand why is this. i have checked that these are the same distros with the same user. they are. and it doesnt really matter which command i insert there, as long as i need password authentication, it fails.

please help.

Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other

A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Marcin Policht 113.6K Reputation points MVP Volunteer Moderator
    2026-11-21T06:40:06.4766667+00:00

    This might be caused by a difference in how the terminal handles interactive input, rather than a different WSL distro, Linux user, or password. VS Code's integrated terminal is not necessarily behaving identically to the Windows Terminal session, even though both connect to the same WSL environment. In particular, password prompts can be affected by terminal settings, shell configuration, how the terminal was launched, or whether the process has access to a proper TTY.

    Since you say this happens with any command requiring password authentication, I'd start by checking whether sudo can correctly read interactive input from the VS Code terminal.

    1. Compare the two terminals

    Run these commands in both the working Windows Terminal and the failing VS Code terminal:

    whoami
    id
    tty
    echo "$SHELL"
    echo "$TERM"
    stty -a
    

    Focus on tty. Both should report a valid terminal device, such as /dev/pts/0 or /dev/pts/1. The numbers do not have to match.

    1. Test sudo authentication independently

    In the VS Code terminal, run:

    sudo -k
    sudo -v
    

    sudo -k clears the cached authentication, forcing the next sudo command to request your password. sudo -v tests authentication without actually installing anything.

    Type the password manually rather than pasting it.

    1. Check keyboard input

    If the password contains special characters, test whether the keyboard layout or character input differs between Windows Terminal and VS Code. Linux does not display anything when you type a password, not even asterisks, so it is easy to miss an input problem.

    1. Check how VS Code was launched

    If you normally launch VS Code from Windows, try launching it directly from the working WSL terminal:

    cd /path/to/your/project
    code .
    

    This should help identify whether the issue relates to how VS Code initializes its WSL environment.


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.