Git Bash and Pageant are not using keys

Git Bash and Pageant are not using keys

This is what ended up working for me.

BTW, I do have Bash on Windows as well, but I don't think that matters.

I had Sourcetree installed and pointed at its folder with plink.exe, puttygen.exe, & pageant.exe. You could also download and install these separately as well.

Configure Windows Environment Variable

  1. Type Environment into your Windows 10 search bar. Otherwise, open up System Properties / Advanced System Settings and find your Environment Variables.
  2. Add a new System variable
    • Variable Name: GIT_SSH
    • Variable Value: full path to plink.exe file (you may also have pageant.exe and puttygen.exe in the same folder).
      • Mine was: C:\Program Files (x86)\Atlassian\SourceTree\tools\putty\plink.exe

      • Note: Newer versions of Sourcetree seem to install ot %localappdata%. The tools are located at %localappdata%\SourceTree\app-x.x.x\tools\putty

      • Note: The newer Sourcetree (v2 on Windows) uses versioned directories, so every time you update it, you'll have to update this which is a pain. It is best to just make a copy of plink.exe and put it somewhere that's not going to change.

      • If you have any of the above programs running you can always open up task manager, find the process, and open up the folder location to get the path to plink.exe.

Profit

Make sure to restart your terminals so that they get the updated environment variables. For me, I was running Bash for my integrated terminal within Visual Studio Code, so I had to restart Visual Studio Code. It would have surely been acceptable to close the integrated terminal and open a new one, but I also wanted the built in git functionality in Visual Studio Code to work as well.

Note

Given that I have Sourcetree installed I was able to use its interface to clone down out of Bitbucket and push through its interface, but trying through terminals was not working, because they were using a different credential set.

Another interesting thing to point out is that if you navigate into your project's git configuration located at: ./.git/config, you could swap out your remote from using SSH to HTTPS. You can grab the following values from your Overview on your Bitbucket repository.

  • ssh layout: git@bitbucket.org:USERNAME/REPO_NAME.git
  • https layout: https://USERNAME@bitbucket.org/USERNAME/REPO_NAME.git

I noticed while using HTTPS on Windows 10 it then will use the Windows Credential Manager (I tried adding my credentials to it while trying to figure this out myself, but I was still using SSH so it didn't matter) When you go to interact with the remote repository it will prompt you for your credentials and store them for later use in Windows Credential Manager :)

Hopefully one of these methods will work out for you. The HTTPS method will skip the whole SSH key generation and pushing it up into Bitbucket, but it feels more secure and portable for me.

Mac OS

You may need to add your key to the keychain especially if you're using Visual Studio Code and have a passphrase on your key (currently Visual Studio Code will not allow you to type in a passphrase).

ssh-add -K ~/.ssh/id_rsa

https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#adding-your-ssh-key-to-the-ssh-agent

Additions

I'm not sure if these may be helpful for someone, but I've been following getting SSH support into Visual Studio Code for Windows: https://github.com/Microsoft/vscode/issues/13680.

 

回答2

You are mixing things up.

PuTTY and Pageant are not compatible with OpenSSH tools and can't communicate together. PuTTY can't read keys from your OpenSSH agent and OpenSSH can't read the keys from Pageant. The key format is also different. That is a bad thing in this world, but there is no solution on the horizon.

Also "agent forwarding" is something different than "using agent".

If you set up Git with plink (make sure you really did), check if your Pageant is running and if the option "Attempt authentication using Pageant" is checked in your stored profile in PuTTY under ConnectionSSHAuth.

If it will not resolve your problems, post some debug log from PuTTY.

 

 

 

 

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(51)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2020-10-21 codedom roslyn compilation error
2019-10-21 Check if List<Int32> values are consecutive
2019-10-21 comparison of truncate vs delete in mysql/sqlserver
2016-10-21 Group By
2016-10-21 The property 'RowId' is part of the object's key information and cannot be modified.
2016-10-21 HashCheck
2016-10-21 File Checksum Integrity Verifier
点击右上角即可分享
微信分享提示