// 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");
}