tomaswolf commented on issue #421:
URL: https://github.com/apache/mina-sshd/issues/421#issuecomment-1739981592

   A server example _does_ exist at 
[SshServerMain](https://github.com/apache/mina-sshd/blob/master/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java).
 Note that it is insecure: it allows any password log-in where the password 
equals the user name given, and it accepts any public key.
   
   If you want it even simpler: here's a quick'n'dirty hack I sometimes use for 
testing:
   ```
   import java.nio.file.Paths;
   import java.time.Duration;
   
   import org.apache.sshd.common.session.SessionHeartbeatController;
   import org.apache.sshd.server.SshServer;
   import org.apache.sshd.server.forward.AcceptAllForwardingFilter;
   import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
   import org.apache.sshd.server.shell.InteractiveProcessShellFactory;
   
   public class TestServer {
   
       public static void main(String[] args) throws Exception {
           SshServer sshd = SshServer.setUpDefaultServer();
           sshd.setPort(12133);
           SimpleGeneratorHostKeyProvider hostKeys = new 
SimpleGeneratorHostKeyProvider(Paths.get("/tmp/a.ser"));
           sshd.setShellFactory(InteractiveProcessShellFactory.INSTANCE);
           
sshd.setSessionHeartbeat(SessionHeartbeatController.HeartbeatType.IGNORE, 
Duration.ofSeconds(5));
           sshd.setKeyPairProvider(hostKeys);
           hostKeys.loadKeys(null);
           sshd.setPasswordAuthenticator((username, password, session) -> true);
           sshd.setPublickeyAuthenticator((username, pubkey, session) -> true);
           sshd.setForwardingFilter(AcceptAllForwardingFilter.INSTANCE);
           sshd.start();
           Thread.sleep(10000000);
       }
   }
   ```
   Listens on port 12133 and allows any password or public key.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to