class SshUtils implements InitializingBean {

    public void executeCommandOnHostViaSsh(String hostIp, String command) {
        Connection sshConnectionWithHost = getSshConnectionWithHost(hostIp);
        try {
            Session sshSession = authenticateSshSessionWithPublicKey(sshConnectionWithHost);
            sshSession.execCommand(command);
            waitUntilCommandFinishes(hostIp, command, sshSession);
            sshSession.close();
        } catch (IOException e) {
            logger.info("Unable to execute command: " + command, e);
        }
        sshConnectionWithHost.close();
    }

}