Is there a better way to update known_hosts when using PuTTY's ssh for git?

I've been able to configure git/Windows 7 to use PuTTY's plink to authenticate with Stash. However, the weak link of this method is that PuTTY does not provide the "do you trust this host? (yes/no)" prompt so I have to add Stash as a trusted host using gits ssh prior to configuring PuTTY and then importing the known_hosts using the Python kh2reg.py script. Is there a way to add stash to PuTTY's known_hosts file without doing this python hack?

BTW, for me, msysGit ssh resulted in 1 MiB/s throuput while PuTTY ssh resulted in 5 MiB/s throughput. I still don't understand why this is so slow, but it's a 5x improvement.

<h6>Install PuTTY</h6>

Install putty (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) to a directory that does not contain spaces in the path. Example: c:\tools\PuTTY. If the path to putty includes spaces, the GIT_SSH environment variable cannot be used to point to plink correctly.

<h6>Set GIT_SSH</h6>

Set a system variable that sets GIT_SSH to the location of plink.exe in the putty installation. Example: GIT_SSH=c:\tools\PuTTY\plink.exe

<h6>Import keys into PuTTY</h6>

Run the PuTTY GUI puttygen to import the ssh private key. Save the PuTTY key as ~/.ssh/id_rsa.ppk.

<h6>Start pageant</h6>

This needs to be started each time you reboot.

C:\tools\putty\pagent.exe C:\Users\USERID\.ssh\id_rsa.ppk

<h6>Install Python</h6> <h6>Import known_hosts</h6>

PuTTY stores it's known_hosts into the Windows registry. I've not figured out how to cause PuTTY to accept Stash as a known host due to not being able to login to Stash using PuTTY. To get around this, the known_hosts file is imported using kh2reg.py (http://svn.tartarus.org/*checkout*/sgt/putty/contrib/kh2reg.py?revision=8519)

cd ~/.ssh

python kh2reg.py > hosts.reg

Then, double click on hosts.reg from the windows explorer.

2 answers

1 accepted

MsysGit 1.8.3 release notes state: "If configured to use Plink, you will have to connect with putty first and accept the host key."

Note: I've found that git HTTPS is faster than both PuTTY SSH and Windows git SSH.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

29,162 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you