Pardon my ignorance, but I am fairly new to groovy. Can you please tell me if this looks ok?
import com.jcraft.jsch.JSch
import com.santaba.agent.util.Settings
host = hostProps.get("system.hostname")
user = hostProps.get("ssh.user")
pass = hostProps.get("ssh.pass")
port = hostProps.get("ssh.port")?.toInteger() ?: 22
//cert = hostProps.get("ssh.cert") ?: '~/.ssh/id_rsa'
timeout = 15000 // timeout in milliseconds
try {
jsch = new JSch()
session = jsch.getSession(user, host, port)
session.setConfig("StrictHostKeyChecking", "no");
String authMethod = Settings.getSetting(Settings.SSH_PREFEREDAUTHENTICATION, Settings.DEFAULT_SSH_PREFEREDAUTHENTICATION);
session.setConfig("PreferredAuthentications", authMethod);
if (user && pass)
{ session.connect() }
}
catch(Exception e) {
System.out.println(e);
}
finally {
session.disconnect()
}