Starting PuTTY from an exported HTML diagram

Consider a following scenario: you have a diagram containing network devices (servers) and you want to start PUTTY client when any of those devices is clicked to open SSH session to a corresponding device. And you want that to be on a webpage.

A possible solution to that on windows is to register a custom application protocol and map it to launch an executable. You can see a common example when “callto:” link opens Skype. Here are some explanations. This works for all major browsers, works also in Visio (without any macros).

With Visio (and a tiny SVG Publish script), this approach can be customized. Suppose you have a rack diagram, which already has all server addresses ready. SVG Publish can convert the data into custom links that can be used to launch an executable (PuTTY in this example).

All you need to do is one registry modification on the machine(s) where you want to use it. These can be user-level or machine-level (do not require admin permissions). You need to register custom protocol. The file below contains a sample suitable for PuTTY.

To get started:

  • Download the script that registers custom protocol (SSH):  Putty-html (1.5 KiB) – important!
  • Run the _install.bat file – this will register the handler, so that “ssh://” links are opened. To remove, run the _uninstall.bat file
  • To test that protocol works: try typing “ssh://github.com” in the browser address line. This should bring putty prompt. You can also play with this example (opens PuTTY to github.com or nethack.alt.org).
  • Now you should be able to use links like the one above to start putty; note that in Visio you can define those using standard “Add hyperlink” UI. Also note that this approach works without macros added to Visio file(s)!
  • For SVG Publish and Rack-type diagram for example, you could use a stock gist script that will create links for you out of the shape data (assuming you are using standard Rack shape, the address will be “IP Address” – if not, it’s just a few lines – adapting should be easy). This script checks if shape data has “IP Address”, and if so, it adds a “ssh://” hyperlink  “click” event handler for the shape – so that when clicked, it triggers PuTTY to open.

Note that using this technique basically you can start executable of your choice, of course it’s not limited to putty 🙂

Leave a Reply