private SSHSocketImplFactory(String host) throws JSchException, IOException { JSch jsch = new JSch(); jsch.setLogger(this); String passphrase = ""; String defaultSSHDir = System.getProperty("user.home") + "/.ssh"; String identityFile = defaultSSHDir + "/openid"; String user = System.getProperty("user.name"); user = System.getProperty("ssh.user", user); if (host == null) { throw new RuntimeException( "ssh.gateway system property must be set"); } String knownHosts = defaultSSHDir + "/known_hosts"; knownHosts = System.getProperty("ssh.knownhosts", knownHosts); jsch.setKnownHosts(knownHosts); identityFile = System.getProperty("ssh.identity", identityFile); jsch.addIdentity(identityFile, passphrase.getBytes()); session = jsch.getSession(user, host); Properties props = new Properties(); props.put("compression.s2c", "none"); props.put("compression.c2s", "none"); props.put("cipher.s2c", "blowfish-cbc,3des-cbc"); props.put("cipher.c2s", "blowfish-cbc,3des-cbc"); if (jsch.getHostKeyRepository().getHostKey(host, null) == null) { // We don't have a way to prompt, so if it isn't there we want // it automatically added. props.put("StrictHostKeyChecking", "no"); } session.setConfig(props); session.setDaemonThread(true); // We have to make sure that SSH uses it's own socket factory so // that we don't get recursion SocketFactory sfactory = new SSHSocketFactory(); session.setSocketFactory(sfactory); UserInfo userinfo = null; session.setUserInfo(userinfo); session.connect(); if (!session.isConnected()) { throw new IOException("Session not connected"); } }