Wednesday, February 22, 2017

Run PuTTy from your Items/Machines in vRealize Automation

There is a build in day2operation in vRealize Automation called 'Connect using SSH' which should allow you to connect your virtual machine following a ssh:// link. Unfortunately such ssh:// links can per default not be executed and you retrieve an error like this:
'There is no program associated to perform the requested action. Please install a program or, if one is already installed, create an association in the Default Programs control panel.'


To enable the 'Connect using SSH' day2operation on your linux virtual machines, follow the official instructions on: pubs.vmware.com...D7005E0578.html (still valid for later versions).

First of all, for PuTTy we need to create a 'putty.bat' file which translates the link into something PuTTy can handle. So we create a batch file with the following content in the same directory than our putty.exe file is (in my example within C:\Programs\PuTTy):
@ECHO OFF
set parameter=%1%
set ssh=%parameter:ssh://=%
set ssh=%ssh:/=%
start C:\Programs\PuTTY\putty.exe -ssh %ssh%

To create an association to our batch file for PuTTy, for a ssh:// link, we need to add some registry keys to the desktops Windows registry where you want to open the ssh:// links later.
To do so, create a 'ssh.reg' file with the following content and execute it as administrator. You may need to confirm you want to execute the file.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\telnet]
@="URL:Telnet Protocol"
"EditFlags"=dword:00000002
"FriendlyTypeName"="@ieframe.dll,-907"
"URL Protocol"=""
"BrowserFlags"=dword:00000008
[HKEY_CLASSES_ROOT\telnet\DefaultIcon]
@="C:\Programs\PuTTY\putty.exe,0"
[HKEY_CLASSES_ROOT\telnet\shell]
@=""
[HKEY_CLASSES_ROOT\telnet\shell\open]
[HKEY_CLASSES_ROOT\telnet\shell\open\command]
@="C:\Programs\PuTTY\putty.exe %1%"
[HKEY_CLASSES_ROOT\ssh]
@="URL:SSH Protocol"
"EditFlags"=dword:00000002
"FriendlyTypeName"="@ieframe.dll,-907"
"URL Protocol"=""
"BrowserFlags"=dword:00000008
[HKEY_CLASSES_ROOT\ssh\DefaultIcon]
@="C:\Programs\PuTTY\putty.exe,0"
[HKEY_CLASSES_ROOT\ssh\shell]
@=""
[HKEY_CLASSES_ROOT\ssh\shell\open]
[HKEY_CLASSES_ROOT\ssh\shell\open\command]
@="C:\Programs\PuTTY\putty.bat %1%"
[HKEY_CLASSES_ROOT\putty]
@="URL:PuTTY Protocol"
"EditFlags"=dword:00000002
"FriendlyTypeName"="@ieframe.dll,-907"
"URL Protocol"=""
"BrowserFlags"=dword:00000008
[HKEY_CLASSES_ROOT\putty\DefaultIcon]
@="C:\Programs\PuTTY\putty.exe,0"
[HKEY_CLASSES_ROOT\putty\shell]
@=""
[HKEY_CLASSES_ROOT\putty\shell\open]
[HKEY_CLASSES_ROOT\putty\shell\open\command]
@="C:\Programs\PuTTY\putty.bat %1%"

Finaly, you can test your ssh:// link association by simply run a ssh:// link and see putty instantly opening a session to the ip or hostname you provide in the ssh:// link.

No comments:

Post a Comment