title: In memory/embedded SFTP server for test with private key authentication in Java
body: <p>The scenario is that I need to write tests for an application that does SFTP file transfers and I need an <strong>in memory/embedded SFTP server with private key authentication implementation</strong> so that I can test that file transfers run okay with the embedded/ in memory server with private key (.pem) file authentication.</p>
  
  <p>I have raked through the guts of internet the closest I came to was <a href="https://stackoverflow.com/questions/11837948/using-apache-mina-as-a-mock-in-memory-sftp-server-for-unit-testing">Apache Mina Server as discussed in this S.O. question</a></p>
  
  <p>Currently I am using a username and password authentication as below:</p>
  
  <pre><code>SshServer sshd = SshServer.setUpDefaultServer();
  sshd.setPort(22999);
  
  sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
  sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
  
      public boolean authenticate(String username, String password,
                                  ServerSession session) {
          // TODO Auto-generated method stub
          return true;
      }
  });
  </code></pre>
  
  <p>I tried finding a way to implement private key authentication but it seems there is only one authenticator but that is a public key authenticator as below:</p>
  
  <pre><code>public void setPublickeyAuthenticator(PublickeyAuthenticator publickeyAuthenticator) {
      this.publickeyAuthenticator = publickeyAuthenticator;
  }
  </code></pre>
  
  <p>Is there a way to implement private key authenticator with Apache Mina? or if it's impossible there is there any other mock SFTP server I could use for my testing scenario?</p>