55

I have used Puttygen to create a public and a private key, and then is ready to let TortoiseHg on Windows 7 do a clone by going to

ssh://somebody@code.somewhere.com/somecode

but there seems to be no where to add the private key to TortoiseHg? (or even just the mercurial command line)

The file is already some where on hard disk as somefile.ppk Does someone know how to add it?

nonopolarity
  • 146,324
  • 131
  • 460
  • 740
  • 2
    This question is duplicated on SuperUser: http://serverfault.com/questions/147136/how-to-let-tortoisehg-mercurial-on-windows-use-the-private-key-file-generated/147388 I think it belong there instead of StackOverflow since it is not related to programming, but to software in general. – Martin Geisler Jun 02 '10 at 07:56

2 Answers2

83

Either add the following to the [ui]-section of the mercurial.ini in your home directory (assuming your key is in "C:\Users\UserName\mykey.ppk"):

[ui]
ssh = tortoiseplink.exe -ssh -i "C:\Users\UserName\mykey.ppk"

or use Pageant, found in the TortoiseHg installation path (e.g. C:\Program Files\TortoiseHg\Pageant.exe). Start it, double click the taskbar-icon that appears, and add the .ppk-file.

David Tischler
  • 2,642
  • 22
  • 13
  • 2
    i see. thanks. i may add here that the "home directory" on Windows 7 is something like c:\users\peter – nonopolarity Jun 04 '10 at 05:20
  • Note that if you want to specify your username, that can be done with the -l switch for tortoiseplink (add "-l myusername" to this ssh-line) – Touko Mar 25 '11 at 07:41
  • Thanks, this approach can also be used for CCnet build server, just put it in the service accounts home directory – David Martin Nov 29 '12 at 15:57
  • 1
    @HoangTran Use `-pw password` argument to login with the specified password. – david.s Dec 27 '12 at 14:44
  • 3
    @david.s Thanks, but that means password is put in this plaintext .ini file, what I look for is a way to save it securely. – Hoang Tran Jan 02 '13 at 17:19
  • 2
    Starting in TortoiseHg 3.5, `tortoiseplink` isn't added to the PATH by default, so you need to do `ssh = "C:\Program Files\TortoiseHg\lib\tortoiseplink.exe" -ssh -i "C:\Users\UserName\mykey.ppk"` instead – Josh Noe Jun 03 '19 at 18:55
  • Also, you may not have tortiseplink.exe installed by default; that was the next prob for me. – cham Aug 04 '20 at 23:46
0

need an ssh key generator first

  1. cmd: ssh-keygen -t rsa
  2. open PuTTY Key Generator
  3. Conversions > import key: open the id_rsa file in C:\Users\.ssh (you may have to create the folder !must run cmd as Admin!)
  4. Save the imported file id_rsa as id_rsa.ppk
  5. Open Pageant.exe in TortoiseHG folder
  6. It will show up in Taskbar
  7. Right click and click add keys
  8. Finally add your new ppk file

Oh right copy the contents of id_rsa.pub to hg host

Mark
  • 2,167
  • 4
  • 32
  • 64
user1198289
  • 637
  • 1
  • 5
  • 14