private SSHShellInputs getSshShellInputs(OsDetectorInputs osDetectorInputs) { SSHShellInputs sshShellInputs = new SSHShellInputs(); sshShellInputs.setHost(osDetectorInputs.getHost()); sshShellInputs.setPort(defaultIfEmpty(osDetectorInputs.getPort(), valueOf(DEFAULT_PORT))); sshShellInputs.setUsername(osDetectorInputs.getUsername()); sshShellInputs.setPassword(osDetectorInputs.getPassword()); sshShellInputs.setPrivateKeyFile(osDetectorInputs.getPrivateKeyFile()); sshShellInputs.setPrivateKeyData(osDetectorInputs.getPrivateKeyData()); sshShellInputs.setAgentForwarding(osDetectorInputs.getAgentForwarding()); sshShellInputs.setTimeout(osDetectorInputs.getSshTimeout()); sshShellInputs.setConnectTimeout(osDetectorInputs.getSshConnectTimeout()); sshShellInputs.setCloseSession(valueOf(true)); sshShellInputs.setKnownHostsPolicy(osDetectorInputs.getKnownHostsPolicy()); sshShellInputs.setKnownHostsPath(osDetectorInputs.getKnownHostsPath()); sshShellInputs.setAllowedCiphers(osDetectorInputs.getAllowedCiphers()); sshShellInputs.setProxyHost(osDetectorInputs.getProxyHost()); sshShellInputs.setProxyPort(osDetectorInputs.getProxyPort()); sshShellInputs.setProxyUsername(osDetectorInputs.getProxyUsername()); sshShellInputs.setProxyPassword(osDetectorInputs.getProxyPassword()); sshShellInputs.setCommand(OS_DETECTOR_COMMAND); sshShellInputs.setUseShell(valueOf(false)); sshShellInputs.setSshGlobalSessionObject(new GlobalSessionObject<Map<String, SSHConnection>>()); return sshShellInputs; } }
if (StringUtilities.isEmpty(sshShellInputs.getCommand())) { throw new RuntimeException(COMMAND_IS_NOT_SPECIFIED_MESSAGE); if (sshShellInputs.getArguments() != null) { sshShellInputs.setCommand(sshShellInputs.getCommand() + " " + sshShellInputs.getArguments()); int portNumber = StringUtils.toInt(sshShellInputs.getPort(), Constants.DEFAULT_PORT); String knownHostsPolicy = StringUtils.toNotEmptyString(sshShellInputs.getKnownHostsPolicy(), Constants.DEFAULT_KNOWN_HOSTS_POLICY); Path knownHostsPath = StringUtils.toPath(sshShellInputs.getKnownHostsPath(), Constants.DEFAULT_KNOWN_HOSTS_PATH); sessionId = "sshSession:" + sshShellInputs.getHost() + "-" + portNumber + "-" + sshShellInputs.getUsername(); ConnectionDetails connection = new ConnectionDetails(sshShellInputs.getHost(), portNumber, sshShellInputs.getUsername(), sshShellInputs.getPassword()); IdentityKey identityKey = IdentityKeyUtils.getIdentityKey(sshShellInputs.getPrivateKeyFile(), sshShellInputs.getPrivateKeyData(), sshShellInputs.getPassword()); KnownHostsFile knownHostsFile = new KnownHostsFile(knownHostsPath, knownHostsPolicy); if (service == null || !service.isConnected()) { saveSSHSession = true; ProxyHTTP proxyHTTP = ProxyUtils.getHTTPProxy(sshShellInputs.getProxyHost(), sshShellInputs.getProxyPort(), sshShellInputs.getProxyUsername(), sshShellInputs.getProxyPassword()); service = new SSHServiceImpl(connection, identityKey, knownHostsFile, sshShellInputs.getConnectTimeout(), sshShellInputs.isAllowExpectCommands(), proxyHTTP, sshShellInputs.getAllowedCiphers());
if (StringUtils.isEmpty(sshShellInputs.getCommand())) { throw new RuntimeException(COMMAND_IS_NOT_SPECIFIED_MESSAGE); if (sshShellInputs.getArguments() != null) { sshShellInputs.setCommand(sshShellInputs.getCommand() + " " + sshShellInputs.getArguments()); int portNumber = StringUtils.toInt(sshShellInputs.getPort(), Constants.DEFAULT_PORT); String knownHostsPolicy = StringUtils.toNotEmptyString(sshShellInputs.getKnownHostsPolicy(), Constants.DEFAULT_KNOWN_HOSTS_POLICY); Path knownHostsPath = StringUtils.toPath(sshShellInputs.getKnownHostsPath(), Constants.DEFAULT_KNOWN_HOSTS_PATH); sessionId = "sshSession:" + sshShellInputs.getHost() + "-" + portNumber + "-" + sshShellInputs.getUsername(); ConnectionDetails connection = new ConnectionDetails(sshShellInputs.getHost(), portNumber, sshShellInputs.getUsername(), sshShellInputs.getPassword()); KeyFile keyFile = getKeyFile(sshShellInputs.getPrivateKeyFile(), sshShellInputs.getPassword()); KnownHostsFile knownHostsFile = new KnownHostsFile(knownHostsPath, knownHostsPolicy);
@Param(Constants.CLOSE_SESSION) String closeSession) { SSHShellInputs sshShellInputs = new SSHShellInputs(); sshShellInputs.setHost(host); sshShellInputs.setPort(port); sshShellInputs.setUsername(username); sshShellInputs.setPassword(password); sshShellInputs.setPrivateKeyFile(privateKeyFile); sshShellInputs.setCommand(command); sshShellInputs.setArguments(arguments); sshShellInputs.setCharacterSet(characterSet); sshShellInputs.setPty(pty); sshShellInputs.setAgentForwarding(agentForwarding); sshShellInputs.setTimeout(timeout); sshShellInputs.setSshGlobalSessionObject(globalSessionObject); sshShellInputs.setCloseSession(closeSession); sshShellInputs.setKnownHostsPolicy(knownHostsPolicy); sshShellInputs.setKnownHostsPath(knownHostsPath);
if (StringUtilities.isEmpty(sshShellInputs.getCommand())) { throw new RuntimeException(COMMAND_IS_NOT_SPECIFIED_MESSAGE); if (sshShellInputs.getArguments() != null) { sshShellInputs.setCommand(sshShellInputs.getCommand() + " " + sshShellInputs.getArguments()); int portNumber = StringUtils.toInt(sshShellInputs.getPort(), Constants.DEFAULT_PORT); String knownHostsPolicy = StringUtils.toNotEmptyString(sshShellInputs.getKnownHostsPolicy(), Constants.DEFAULT_KNOWN_HOSTS_POLICY); Path knownHostsPath = StringUtils.toPath(sshShellInputs.getKnownHostsPath(), Constants.DEFAULT_KNOWN_HOSTS_PATH); sessionId = "sshSession:" + sshShellInputs.getHost() + "-" + portNumber + "-" + sshShellInputs.getUsername(); ConnectionDetails connection = new ConnectionDetails(sshShellInputs.getHost(), portNumber, sshShellInputs.getUsername(), sshShellInputs.getPassword()); IdentityKey identityKey = IdentityKeyUtils.getIdentityKey(sshShellInputs.getPrivateKeyFile(), sshShellInputs.getPrivateKeyData(), sshShellInputs.getPassword()); KnownHostsFile knownHostsFile = new KnownHostsFile(knownHostsPath, knownHostsPolicy); if (service == null || !service.isConnected()) { saveSSHSession = true; ProxyHTTP proxyHTTP = ProxyUtils.getHTTPProxy(sshShellInputs.getProxyHost(), sshShellInputs.getProxyPort(), sshShellInputs.getProxyUsername(), sshShellInputs.getProxyPassword()); service = new SSHServiceImpl(connection, identityKey, knownHostsFile, sshShellInputs.getConnectTimeout(), sshShellInputs.isAllowExpectCommands(), proxyHTTP, sshShellInputs.getAllowedCiphers());
@Param(Constants.USE_SHELL) String useShell) { SSHShellInputs sshShellInputs = new SSHShellInputs(); sshShellInputs.setHost(host); sshShellInputs.setPort(port); sshShellInputs.setUsername(username); sshShellInputs.setPassword(password); sshShellInputs.setPrivateKeyFile(privateKeyFile); sshShellInputs.setPrivateKeyData(privateKeyData); sshShellInputs.setCommand(command); sshShellInputs.setArguments(arguments); sshShellInputs.setCharacterSet(characterSet); sshShellInputs.setPty(pty); sshShellInputs.setAgentForwarding(agentForwarding); sshShellInputs.setTimeout(timeout); sshShellInputs.setConnectTimeout(connectTimeout); sshShellInputs.setSshGlobalSessionObject(globalSessionObject); sshShellInputs.setCloseSession(closeSession); sshShellInputs.setKnownHostsPolicy(knownHostsPolicy); sshShellInputs.setKnownHostsPath(knownHostsPath); sshShellInputs.setAllowedCiphers(allowedCiphers); sshShellInputs.setProxyHost(proxyHost); sshShellInputs.setProxyPort(proxyPort); sshShellInputs.setProxyUsername(proxyUsername); sshShellInputs.setProxyPassword(proxyPassword); sshShellInputs.setAllowExpectCommands(allowExpectCommands); sshShellInputs.setUseShell(useShell);
@Param(Constants.USE_SHELL) String useShell) { SSHShellInputs sshShellInputs = new SSHShellInputs(); sshShellInputs.setHost(host); sshShellInputs.setPort(port); sshShellInputs.setUsername(username); sshShellInputs.setPassword(password); sshShellInputs.setPrivateKeyFile(privateKeyFile); sshShellInputs.setPrivateKeyData(privateKeyData); sshShellInputs.setCommand(command); sshShellInputs.setArguments(arguments); sshShellInputs.setCharacterSet(characterSet); sshShellInputs.setPty(pty); sshShellInputs.setAgentForwarding(agentForwarding); sshShellInputs.setTimeout(timeout); sshShellInputs.setConnectTimeout(connectTimeout); sshShellInputs.setSshGlobalSessionObject(globalSessionObject); sshShellInputs.setCloseSession(closeSession); sshShellInputs.setKnownHostsPolicy(knownHostsPolicy); sshShellInputs.setKnownHostsPath(knownHostsPath); sshShellInputs.setAllowedCiphers(allowedCiphers); sshShellInputs.setProxyHost(proxyHost); sshShellInputs.setProxyPort(proxyPort); sshShellInputs.setProxyUsername(proxyUsername); sshShellInputs.setProxyPassword(proxyPassword); sshShellInputs.setAllowExpectCommands(allowExpectCommands); sshShellInputs.setUseShell(useShell);