Search code examples
visual-studio-codesshvscode-remote

VS Code - Remote (SSH) failing - repeatedly asking for password and getting "Permission Denied." I have an SSH key that is not being submitted


I have already solved this issue and will respond with an answer shortly. I am posting this question so that it can be found by others in the future, since I did not find anything with my original search terms and think other users may be in a similar boat.

I have been using VS Code's Remote (SSH) extension for quite some time and have been happy with it. Today, I cleaned out my SSH config file to remove unused connections and am now unable to connect to the host I have been using.

Now, when I attempt to connect to the host, I am just repeatedly asked for my password and the permission is denied. Since I am using SSH keys, it is unusual that I am being asked for my user password in the first place, much less that the correct password is being repeatedly denied.

My SSH config file is in the default location (Windows -- "C:\Users\username\.ssh\config"). These are its contents:

Host primary_host
    HostName primary_hostname
    User username
    ProxyJump proxy_host

I have noticed that, when asking for the password to connect, my username is instead being submitted with my Windows username, including the domain. i.e. "domain\username@proxy_host".


Solution

  • It turned out that, when I cleaned out my SSH config, I removed the ProxyJump host connection because I never connected directly to it.

    This resulted in the ssh connection to the proxy_host defaulting to a login User of the windows user, which was "domain\username@proxy_host". That user does not exist on the final/target host, so I was being asked for a password that did not exist.

    There are two ways to fix this:

    1. Change the "ProxyJump" field to "username@proxy_host"
    Host primary_host
        HostName primary_hostname
        User username
        ProxyJump username@proxy_host
    
    1. Add another entry for the proxy_host in your SSH config:
    Host proxy_host
        HostName proxy_host
        User username
    

    Making either of these changes results in the connection working properly!