Hey ppl...
Just wanted to share my approach on having the complete set of putty tools in a really portable way.
The principles
The whole approach is based on the following principles:
- I want to use the original release of putty, and not any alternative - i completely agree with John on the fact that the reason we use putty is because we trust it.
- I don't want to "hack" - I want to go with the simplest of approaches, using the platform tools - PortableApps.com Launcher and Installer.
- I want to have my keys with me on my usb - encryption and safety is taken care of from other applications. I want putty to be aware of my keys and use them.
- I want to have an integrated experience from other applications that use putty, without any extra effort from either side.
Reading through the forums, there were some interesting approaches and i got a couple of ideas. After some research, I ended up with - what I think to be - a solution to my putty problems. What I did was alter John's launcher to "focus" on peageant instead of putty, making use of its command line parameters to accomplish my goals.
The launcher
[Environment]
KeysFolder=%PAL:DataDir%\keys
[Launch]
ProgramExecutable=PuTTYSuitePortable.cmd
WorkingDirectory=%PAL:AppDir%\putty
HideCommandLineWindow=true
DirectoryMoveOK=yes
WaitForExe1=putty.exe
WaitForExe2=PAGEANT.exe
WaitForExe3=PLINK.exe
WaitForExe4=PSCP.exe
WaitForExe5=PSFTP.exe
WaitForExe6=PUTTYGEN.exe
The launcher ini file is modified so that it invokes a batch file instead of an executable. The WaitForExe keys ensure that the portableapp will stay active as long as any of the putty tools is running. I also use an environmental variable for the location of the key files.
The batch file
@rem Do not use "echo off" to not affect any child calls.
@setlocal enabledelayedexpansion
@set allkeys=
@for %%X in (%KeysFolder%\*.ppk) do @set allkeys=!allkeys! "%%X"
pageant %allkeys% %*
PuTTYSuitePortable.cmd takes care of enumerating the keys folder for key files, passing the paths as parameter to peagent. It also passes any existing parameters that came from the launcher itself. Using this approach, one could create shortcuts like "PuttySuitePortable.exe -c putty.exe". This will be translated in "peagent.exe {keyfiles} -c putty.exe", meaning that putty will be invoked after ensuring that peagent is running with all the available keys loaded. The same goes for any other putty tool - like plink, psftp etc.
Regarding using putty portable with other applications, I have addressed it by making the portableapp start automatically. Since peagent is running, the registry settings are in place and any execution of any of the putty tools - regardless of the location they are executed from or the program that invokes them - works like a charm. In addition, any changes made by using the tools - ie any putty sessions saved, any keys loaded etc - are properly saved and available on my next run.
I have packaged the whole approach to a separate installer. I took the official portable app, renamed it to PuttySuitePortable, made the changes and created an online installer. Be my guests and check it out - and please, do correct me where I am wrong.