Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Pageant doesn't save keys

IchHabRecht May 29, 2013

System:

Windows 7

SourceTree 0.9.4.0

Pageant started by SourceTree



Problem:

- Try to sync repository with local git server (gitolite) with user gitolite@git.local

- SourceTree wants a password which is not necessary

- Open Pageant and import the SSH key for that server

- Everything runs smooth than

- Restart computer / start SourceTree / try to fetch => asking again for a password

- Open Pageant results in an empty Pageant

=> So I have to manually readd my keys to Pageant which is very very annoying!

4 answers

40 votes
Frank Thiemonge
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 1, 2018

I know I'm over five years late to the party, but in case it helps anyone else I had this same issue after creating new keys. I needed to open Tools > Options and on the General tab change the "SSH Key" field to reflect the new name for my private key.

Deleted user April 1, 2019

thx

Terrobladezz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 13, 2019

Awesome! Thanks for the help :)

rajanpatel
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 31, 2019

thanks

chrisadipascual November 15, 2019

You're awesome , thanks for sharing.

yuuji.takahashi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 26, 2020

Good lord, thanks

Mochnant
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 23, 2020

Thanks.

Diliup Gabadamudalige April 28, 2020

Much merit for this tip!

Tony van Loon
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 18, 2020

Thank you!

Alexander-Serov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 21, 2020

Saved me a lot of time!

9 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2013

Pageant doesn't remember its keys unfortunately, but if SourceTree launches Pageant it should pass the contents of the 'SSH Key' setting in Preferences - what does yours say?

When I've tried this with my key present in that SSH Key setting, Pageant always starts up with that key loaded (after I type the passphrase).

shaun-vorster
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 16, 2018

Thank you very much!

Suhail Mahmood
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 20, 2018

Thank you Steve, that worked like a charm. BTW, is there any way I can bypass having to input the pass-phrase for my SSH key (which Pegeant asks so that it can load the key) on launching SourceTree after each PC restart? I am perfectly okay with having to type in the pass-phrase, but just wondering if there is a way to bypass it.

TechnicaLeigh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 18, 2019

Hi Suhail,

I arrived here trying to find the same answer, due to a VM needing to be able to restart and use sFTP without the need to manually type the passphrase for the private key. With nothing "simple" I remembered I'd done some scripting years ago that manipulated dialogue boxes of programs, even opening save dialogues and setting save paths for files from within drafting programs. That was pre-PowerShell though!

After some research, I managed to develop a PowerShell script using bits and pieces that I gathered, so certainly nothing mind blowing, just took some time to tweak!! I'm not claiming it is perfect or the best script, but it works for me.

I've set it to run with Task Scheduler 30 seconds after login, which finds the passphrase prompt pop-up and enters the password.

There are a few ways to encrypt passwords, I used this: https://gallery.technet.microsoft.com/scriptcenter/Encrypt-Password-and-use-dd07f253

I could only get it to work by converting the encrypted password back to plain text, so I do a clear variable at the end, just to add some security. I know converting it to plain text is a security issue and could be hacked, but I am prepared to wear that risk, as it needs to work automatically (being a VM, no one can see the console!). But I figure it is a much smaller risk than having the password in plain text in the script.

We only have one key, it may be possible to amend if you have multiple ones, but I'll leave that to others!

Script below:

***********

Add-Type -AssemblyName microsoft.VisualBasic
Add-Type -AssemblyName System.Windows.Forms
$encrypted = "PASSWORD CONVERTED TO RANDOM NUMBERS (see link above)"
$SecurePassword = $encrypted | ConvertTo-SecureString
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword)
$password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
$app = get-process | where {$_.mainwindowtitle -match "Pageant: Enter Passphrase"}
$processID = 0
foreach ($a in $app) {
if ($a.id -gt $processID) { $processID = $a.id
}
}
start-sleep -Milliseconds 500
[Microsoft.VisualBasic.Interaction]::AppActivate($processID)[System.Windows.Forms.SendKeys]::SendWait("$password{ENTER}")
Clear-Variable -Name "password"

0 votes
Vincent Rozendaal May 29, 2013

The only way that I found was using http://blog.shvetsov.com/2010/03/making-pageant-automatically-load-keys.html which describes how to make a shortcut for pageant that will load multiple keys (but you must still enter the passphrases for those encrypted keys). When I power on my computer I start pageant using the shortcut, enter the passphrases and then I start SourceTree.

0 votes
IchHabRecht May 29, 2013

Okay, this works perfectly for one key. Is there any chance to give just a folder with public keys or even an option to grab keys from the user .ssh folder? Because I have multiple keys for multiple servers in use.

Thanks so much!

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 30, 2013

We do support multiple keys with OpenSSH because you can add them incrementally from the Tools menu after the agent has launched (after which they they appear in the SSH key field in preferences separated by ';'). So far haven't supported that with Pageant because you can't add keys incrementally like that once Pageant is running (at least not from outside it's own interface) - it only works when you launch Pageant with all the keys at once on the command line (see Vincent's answer below about how he does that in his Startup folder - personally this is how I do it too, simply because I use other PuTTY tools outside of SourceTree too).

I will look at supporting multiple keys if you manually configure the SSH key field instead with ';' characters, although that would only work the next time Pageant is re-started.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events