I want to connect to github using SSH protocol in my WSL, i followed every single step from the github documentation here. The key was generated, I've tested my connection, but it still doesn't work. I still have to put username or password everytime i push my code to github. Can anyone help me on this?
I also did this.
# start the ssh-agent in the background
$ eval $(ssh-agent -s)
> Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
PS: I don't know if this is related or not, but I have two .ssh directories in my WSL and my bash root folder. It works in my bash because i guess VS Code generated the SSH key for me.
Edit: I guess it's the ssh-agent that's not working
Git can be installed on Windows AND on WSL The root of your file system / is the mount point of your root partition, or folder, in the case of WSL. Not everything under / is the same drive. For example, on my laptop, I've installed two version of Ubuntu (20.04 and 18.04), as well as Debian.
If you're being prompted for a username and password, it's possible that you're trying to use the HTTPS protocol instead of SSH. You can see what the URL looks like by using git remote -v
. If you want to change to use the SSH protocol, you'd use something like git remote set-url origin [email protected]:git/git.git
(where git/git.git
is the repository you're pushing to).
In general, trying to connect to GitHub over SSH won't prompt you for a username and password, because GitHub doesn't support password authentication over SSH.
On WSL 2, I was using SSH to commit to GitHub and found that I was asked for my password every time. After hours of searching and trying several methods (which worked with caveats I couldn't live with), this is what worked for me.
Install keychain:
sudo apt install keychain
Then add the following line to your shell's configuration file (likely ~/.bashrc
or ~/.zshrc
):
eval `keychain --quiet --eval --agents ssh id_rsa`
Now you will only have to enter your password when booting WSL!
Credit to Birk Holland with this article.
This is followed by eamodio/vscode-gitlens issue 909
I am trying to use git through SSH in a WSL remote.
The SSH connection is protected with a key pair which is password-protected.
How do I start an SSH agent and input that passphrase for a shell in which GitLens operates?By default a bash/wsl shell is opened in terminal window on WSL remote connection.
I start an SSH agent there and add the key, but it seems like this is not the shell in which GitLens is sending its git commands.
A workaround would be to regenerate those keys (after opening first a session with the existing keys) and:
~/.ssh/authorized_keys
file of the WSL session.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With