Was wondering if there is a way to limit the number of attemps mySSHSession tries when establishing a connection. With the basic code below it will try multiple times and ends up locking the specified user account if an incorrect password is used. SSH keys are an option but was just wondering about this specifically.
var mySSHSession = new SSHSession(host,user);
//sample command var cmd = "uptime";
// add logging/debugging as needed
var output = mySSHSession.getOutput();
var error = mySSHSession.getError();
var exitCode = mySSHSession.exitCode;
System.log(host + " - " + "Output: '" + output + "'");
//System.log("Error: '" + error + "'");
//System.log("Exit code: '" + exitCode + "'");
// close out the session:
Not sure what you mean here..
Are you running that in a workflow multiple times in a short amount of time with a bad user & password...
Well.. if it is because the code ran itself 1 times but try multiple time.. you could add a try & catch statement.
<do whatever you want to try here>
Or is it because, you have this code in a workflow and it reties multiple times to ran that workflow if it fails?
The underlying SSH library used by SSH plug-in has a configuration property named MaxAuthTries (default value is 6, if I recall correctly). The problem, however, is that this property is not exposed directly in the vRO scripting API.
Could you insert the following line after the session creation and before connection attempt? Not sure if it will help, but is worth to try.
mySSHSession.addEnvironment("MaxAuthTries", "1"); // "1" for a single attempt; tweak the value as needed
OK, so a new build of SSH plug-in will be needed, with proper support for MaxAuthTries session configuration property.
If you need an urgent fix, I'd suggest to contact your VMware representative to open an official support request. This way, it will get higher priority in the backlog.