You are here

PuTTY: Private key selection

21 posts / 0 new
Last post
miketigerwoods
Offline
Last seen: 17 years 8 months ago
Joined: 2007-03-05 16:11
PuTTY: Private key selection

I used to use local installs of Putty with a private key on my USB drive. Now that this was released I'd like to move it all to my USB drive.

However, when saving the session, I have to select the location for my private key: H:\foo.ppk. If I plug my drive into another computer the drive letter may change.

I tried "\foo.ppk" and that did not work. Is there some %PortableDrive% variable I can use? I looked through the forums and figured I could setup a batch file, though a generic variable that already exists would be better and could easily be added to the support page/FAQ.

John T. Haller
John T. Haller's picture
Offline
Last seen: 2 hours 11 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Where?

Where do you set this up within PuTTY? Are you refering to Connection - SSH - Auth? I must confess it's something I've had no need of, so I hadn't tested. How would one go about using this?

Sometimes, the impossible can become possible, if you're awesome!

miketigerwoods
Offline
Last seen: 17 years 8 months ago
Joined: 2007-03-05 16:11
Yes, that is where you set

Yes, that is where you set the file to use. A private key for putty is imported from an openssh key using puttygen (which is part of the putty suite) then saved as a ppk file. This way you can enable password less connections or enable a stronger authentication scheme. All Putty needs to know is where the key file is located to authenticate the session.

The setting in the .reg file is "PublicKeyFile"="\\foo.ppk" under:
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\SESSIONNAME]

By adding some variable (I'd assume through the PortableApp launcher), you could set the private key location to be something like "PortableDrive%\Documents\privatekey.ppk" to ease the transition from computer to computer and drive letter changes.

John T. Haller
John T. Haller's picture
Offline
Last seen: 2 hours 11 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Hmmm

Depends on whether PuTTY supports environment variables or not (a lot of apps don't). So, does it work on a local install with %USERPROFILE% for instance and then the key within C:\Documents and Settings\[user]\...?

I think I have an idea that would allow you to just pick it from the drive and have the launcher handle the rest (I always go for doing it as easy as possible). Lemme give it a shot and post a new test launcher.

Sometimes, the impossible can become possible, if you're awesome!

miketigerwoods
Offline
Last seen: 17 years 8 months ago
Joined: 2007-03-05 16:11
No, it seems that Putty

No, it seems that Putty doesn't support environment variables. It couldn't find the key file when setting the directory to a variable. I tried a few other environment variables I knew of too and no luck.

John T. Haller
John T. Haller's picture
Offline
Last seen: 2 hours 11 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Kinda Figured

I kinda figured that was the case. I'm working on the fix I have in mind for it. I'll post it as a test release in the next day or so. It'll allow you to pick keys from the portable device just like you normally do and it'll handle the drive letter changes for you.

Sometimes, the impossible can become possible, if you're awesome!

John T. Haller
John T. Haller's picture
Offline
Last seen: 2 hours 11 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Think I got it

I added a search and replace setup to it so that if the drive letter has changed, it'll substitute the new drive letter for the old one in the PublicKeyFile keys in the .reg file. Give this a try:
https://portableapps.com/temp/PuTTYPortable.exe

Sometimes, the impossible can become possible, if you're awesome!

miketigerwoods
Offline
Last seen: 17 years 8 months ago
Joined: 2007-03-05 16:11
Same location

I can't immediately test it using another computer, but I closed down putty and changed the location to Y:\foo.ppk (which is an invalid drive) and replaced the exe with the one above and putty still attempted to connect to the Y:.

The .reg file still showed: "PublicKeyFile"="Y:\\foo.ppk"

John T. Haller
John T. Haller's picture
Offline
Last seen: 2 hours 11 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
No, that's not what I meant

You're not gonna have to manually do anything. While you're using PuTTYPortable connected as, say, drive D, pick your ppk file on that same drive as you normally would and use it. Be sure to save the session.

Now, when you move PuTTY Portable to a new drive (say connecting to a different computer), it'll update the drive letter to the new one. Note that the path must remain the same (eg: \Documents\keys\mykey.ppk).

It updates the driver letter from the last used drive letter to the new drive letter on every launch. It pulls this from the RandomSeed key. So, if you just enter a random invalid drive, it won't work. If you're on a PC that you can't test it on... try editing the .reg to use Y: for both the RandomSeed and your PublicKey and then fire it up and you'll see what I mean.

Sometimes, the impossible can become possible, if you're awesome!

normal
Offline
Last seen: 17 years 8 months ago
Joined: 2007-03-08 08:12
Registering to say your fix

Registering to say your fix works wonderfully. Thanks for another great portable package. I've been wanting this for a while, let me tell you.

[Edit]I found a flaw in your fix: the change doesn't always occur, but I can't seem to find a pattern to it. I only notice it when I don't update all of my sessions as instructed.

miketigerwoods
Offline
Last seen: 17 years 8 months ago
Joined: 2007-03-05 16:11
Works for me

Just got a chance to try it out again and it worked great. Thanks a ton, great work!

germdaily
Offline
Last seen: 8 years 8 months ago
Joined: 2007-04-23 21:41
I can't download the patch

The patch link provided doesn't work. I noticed the build date on the available one is March 2, but your post is dated March 5. Can you please provide me with the patch? Thanks!

heyitsme
Offline
Last seen: 17 years 8 months ago
Joined: 2006-11-23 12:27
Actually, you don't need a

Actually, you don't need a fix at all...

In the reg file, just change this line:
"PublicKeyFile"="M:/whatever/whatever/whatever/Keyring.ppk"
to
"PublicKeyFile"="./Data/Keyring.ppk"

It works perfectly well, even without the patch, 100% of the time.

John T. Haller
John T. Haller's picture
Offline
Last seen: 2 hours 11 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Manual

Except for the fact that it requires you to manually edit a .reg file for every one of your keys, something that users shouldn't have to do. Hence the usefulness of the automated method (which is being posted as an official release tomorrow).

Sometimes, the impossible can become possible, if you're awesome!

heyitsme
Offline
Last seen: 17 years 8 months ago
Joined: 2006-11-23 12:27
No, I just typed in

No, I just typed in ./Data/Keyring.ppk into the settings window of a freshly downloaded copy of Portable PuTTy. It works that way too. But I am glad to hear that there is a usability patch going on behind the scenes. I did not intend to sound like an ass or anything.

acti0nman
acti0nman's picture
Offline
Last seen: 16 years 6 months ago
Joined: 2008-05-14 07:58
How did you figure out that

How did you figure out that ./ would do the trick? I bashed my head for 6 days trying to figure out how to use environment variables, and manipulating pageagent, and plink and all other assortments of stuff.

acti0nman
acti0nman's picture
Offline
Last seen: 16 years 6 months ago
Joined: 2008-05-14 07:58
I guess I just answered my

I guess I just answered my own question. Apparently command prompt DOES understand the backslash. I guess I was under the impression that windows is forward slash only.
Go figure.

C:\Documents and Settings\acti0n\My Documents>cd ./"My Google Gadgets"
C:\Documents and Settings\acti0n\My Documents\My Google Gadgets>

orever
Offline
Last seen: 6 years 7 months ago
Joined: 2007-03-13 15:13
What about pageant?

If one were using the pageant portion of putty, then you wouldn't need to do any of this. Putty would try to get the private key from it. Pageant is completely command-line driven. It might add a little more complexity to the launcher though.

[Moderator RM: Your link has to include a href=" part. I have fixed for you]

klkl
Offline
Last seen: 12 years 4 months ago
Joined: 2008-04-21 21:15
Private key relative file path problem

I have recently downloaded PuTTY Portable but cannot overcome the drive letter change problem when specifying the private key file in Connection > SSH > Auth.

I'm using the latest online version (0.60) but cannot get anything working.

I tried putting my key in the same directory as the executable (DRIVE:\PortableApps\PuTTYPortable\App\putty) and then setting the key to;
key.ppk OR ./key.ppk and neither work.

Can anybody explain where I'm going wrong? It looked like this was going to be fixed but maybe I'm just overlooking something.

acti0nman
acti0nman's picture
Offline
Last seen: 16 years 6 months ago
Joined: 2008-05-14 07:58
klkl: You should stick with

klkl:
You should stick with standards. The Data folder is meant to hold personal configurations. The settings folder is comprised of custom setting that were created directly by the program. I doubt you want to be introducing external files into that particular folder. That's just my take on it, for each their own.

Place your key here:

DRIVE:\PortableApps\PuTTYPortable\Data\key.ppk

Then you can set .Data/key.ppk in Connection > SSH > Auth

klkl
Offline
Last seen: 12 years 4 months ago
Joined: 2008-04-21 21:15
Got it working thanks

acti0nman:
Thanks for your advice I moved the key to the Data folder like you suggested but in order to get Putty to open it I had to set Connection > SSH > Auth to;

PortableApps/PuTTYPortable/Data/key.ppk

in other words I had to use the relative path to the file from the ROOT of the drive.

Log in or register to post comments