1

So for windows, I see the default ssh client config supposed to be placed at C:\Users\Admin\.ssh\config and I use the same, also I am the Admin user.

I added the following ssh client side config:

PS C:\Users\Admin> type .\.ssh\config
Host gc
    HostName gitlab.com
    User git
    IdentityFile ~/.ssh/company_gitlab
Host gp
    HostName gitlab.com
    User git
    IdentityFile ~/.ssh/gitlab_personal

I tested it from Powershell and it is working for both my company and personal GitLab accounts using their respective ssh keys.

PS C:\Users\Admin> ssh -T git@gc
Enter passphrase for key 'C:\Users\Admin/.ssh/company_gitlab':
Welcome to GitLab, @johnwilson!

PS C:\Users\Admin> ssh -T git@gp
Enter passphrase for key 'C:\Users\Admin/.ssh/gitlab_personal':
Welcome to GitLab, @jwilson!

But when it comes to the vscode, when I try to push or pull changes to the remote repository, the following error shows up for both the company and personal GitLab accounts.

> git push -u gc master
[email protected]: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.

> git push -u gp master
[email protected]: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.

I tried the suggestion from here as well

PS C:\Users\Admin\ownCloud\Company\GitLab\userlist> git remote add origin git@gc:company/infra_code/userlist.git
PS C:\Users\Admin\ownCloud\Company\GitLab\userlist> git remote -v
origin  git@gc:company/infra_code/userlist.git (fetch)
origin  git@gc:company/infra_code/userlist.git (push)

PS C:\Users\Admin\ownCloud\Company\GitLab\userlist> git ls-remote origin
Enter passphrase for key 'C:\Users\Admin/.ssh/company_gitlab':
611b36ef47056773c288499cb6974d8671196d78        HEAD
611b36ef47056773c288499cb6974d8671196d78        refs/heads/master

I am confused, so vscode does not pick the default ssh client config C:\Users\Admin\.ssh\config on windows ?.

Or am I missing something?.

2

1 Answer 1

1

Check the remote URL associated with the remote named 'gc'

cd C:\path\to\gc\repo
git remote -v

If the URL starts with [email protected]:..., it won't use the ~/.ssh/config file, and its gc entry.

Change it with the proper URL

git remote set-url gc gc:<me>/<myrepo>

Then VSCode will pick up the right entry, assuming is is running as User Admin.


The OP JohnW confirms in the discussion:

I added an SSH key without a passphrase, which is working for vscode. So this is bug with VSCode cannot connect with ssh key with passphrase?

You need to make sure ssh-agent is activated first.
See "Auto-launching ssh-agent on Git for Windows"

Once the SSH agent is launched (and your private SSH keys passphrase cached in it), you can launch VSCode. It should work then.

Sign up to request clarification or add additional context in comments.

8 Comments

Yeh, I see it is already done, still not working for vscode.
@JohnW Do you mean the remote URL is actually gc:<me>/<myrepo>, and is named gc?
Yes. PS C:\Users\Admin\ownCloud\Company\GitLab\userlist> git remote -v Output: gc gc:company/infra_code/userlist.git (fetch) gc gc:company/infra_code/userlist.git (push)
@JohnW In command li,e, as user admi, would a git ls-remote gc work? (it should just return the list of remote branches, without fetching anything: a good lightweight test)
Yes, CLI always work, only issue with vscode. PS C:\Users\Admin\ownCloud\Company\GitLab\userlist> git ls-remote gc Enter passphrase for key 'C:\Users\Admin/.ssh/company_gitlab': 611b36ef47056773c288499cb6974d8671196d78 HEAD 611b36ef47056773c288499cb6974d8671196d78 refs/heads/master
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.