title: Apache SSHD & JSCH
body: <p>I want mocking ssh server for transfer file. For do it i wand use Apache Mina SSHD. For transfer in system use JSch. with private key.</p>
  
  <p>JSch client code.</p>
  
  <pre><code>    JSch jSch = new JSch();
      jSch.addIdentity(privateKeyPath, passPhrase);
      Session session = jSch.getSession(usernamePlans, remoteHost);
      session.setHost(remoteHostPort);
      config.setProperty("StrictHostKeyChecking", "no");
      session.setConfig(config);
      session.setUserInfo(new StorageUserInfo(passPhrase));
      session.connect();
  </code></pre>
  
  <p>Apache Mina SSHD code </p>
  
  <pre><code>    sshd = SshServer.setUpDefaultServer();
      sshd.setPort(22999);
  
      sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(privateKeyPath));
      sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
  
          public boolean authenticate(String username, String password, ServerSession session) {
              // TODO Auto-generated method stub
              return true;
          }
      });
  
      CommandFactory myCommandFactory = new CommandFactory() {
  
          public Command createCommand(String command) {
              System.out.println("Command: " + command);
              return null;
          }
      };
      sshd.setCommandFactory(new ScpCommandFactory(myCommandFactory));
  
      List&lt;NamedFactory&lt;Command&gt;&gt; namedFactoryList = new ArrayList&lt;&gt;();
  
      namedFactoryList.add(new SftpSubsystem.Factory());
      sshd.setSubsystemFactories(namedFactoryList);
  
      sshd.start();
  </code></pre>
  
  <p>Can anybody help me connect JSch and Apache Mina SSHD for transfer file?</p>
  
  <p>StackTrace</p>
  
  <pre><code>com.jcraft.jsch.JSchException: java.net.SocketException: Invalid argument or cannot assign requested address
  
  Caused by: java.net.SocketException: Invalid argument or cannot assign requested address
  </code></pre>