title: How can I check if my host does not allow SSH access
body: <p>I have tried everything to create an SSH connection to my remote MySQL database.</p>
  
  <pre><code>        String user = "user";
          String password = "pass";
          String remoteHost = "host";
          int localPort = 2022;
          int remotePort = 3306;
          Session session = null;
  
          //Try to forward ports
          try
          {
          //Create the JSCH object
          JSch jsch = new JSch();
  
          //Get the session
          session = jsch.getSession(user, remoteHost);
  
          //Set the password
          session.setPassword(password);
  
          //To be able to connect to any host (this is just for testing!)
          session.setConfig("StrictHostKeyChecking", "no");
  
          //Connect the session
          session.connect();
  
          //Set port forward
          session.setPortForwardingL(localPort, "127.0.0.1", remotePort);
  
          //Show message
          System.out.println("Waiting for connections…");
  
          //Exit on return
          InputStreamReader converter = new InputStreamReader(System.in);
          BufferedReader in = new BufferedReader(converter);
          in.readLine();
          }
  
          //Failed
          catch(Exception ex)
          {
          //Message
          System.out.println("Failed to setup tunnel");
  
          //Stack trace
          ex.printStackTrace();
          }
  
          //Clean up
          finally
          {
          try{session.disconnect();} catch(Throwable t) {t.printStackTrace();}
          }
  </code></pre>
  
  <p>Yet I keep getting this error: com.jcraft.jsch.JSchException: java.net.ConnectException: Operation timed out</p>
  
  <p>I don't understand why it is giving me that error because I believe I am using the right information. So my question is, how would I check my host's remote ip and how would I make sure they do allow SSH access?</p>
  
  <p>UPDATE:</p>
  
  <p>I am able to connect to the remote MySQL database through ssh -v user@host. However, in my code I am getting this error:</p>
  
  <p>com.jcraft.jsch.JSchException: PortForwardingL: local port 127.0.0.1:2022 cannot be bound.</p>
  
  <p>I am using a mac, is the local port different in macs?</p>