Dear, apache :


      I have already setup a SshServer and bind the port "4022".



      How can I write to each client's request? Such as socket code follow this 
:



   ServerSocket serverSocket = new ServerSocket(4022,3);
   while (true) {
       Socket socket = serverSocket.accept();
       BufferedReader input = new BufferedReader(new 
InputStreamReader(socket.getInputStream()));
   }



      More anxious, can you help me ?  My code as follows :

   try {
        URL xmlpath = 
SpringApplication.class.getClassLoader().getResource("dsproxy.pem");
        System.out.println(xmlpath.getPath());
        String hostKeyType = AbstractGeneratorHostKeyProvider.DEFAULT_ALGORITHM;
        int hostKeySize = 0;
        SshServer sshServer = SshServer.setUpDefaultServer();
        sshServer.setPort(4022);
        Map<String, Object> props = sshServer.getProperties();
        props.putAll(new HashMap<>());
        List<String> keyFiles = new LinkedList();
        if(xmlpath != null) {
            keyFiles.add(xmlpath.getPath().substring(1));
        }
        KeyPairProvider keyPairProvider = sshServer.setupServerKeys(sshServer, 
hostKeyType, hostKeySize, keyFiles);
        sshServer.setKeyPairProvider(keyPairProvider);
        sshServer.setupServerBanner(sshServer, new HashMap<>());
        sshServer.setPasswordAuthenticator(new JakiroAuthenticator());
        sshServer.setCommandFactory(new 
ScpCommandFactory.Builder().withDelegate(
            commandString -> new 
ProcessShellFactory(GenericUtils.split(commandString, ' ')).create()
        ).build());
        sshServer.start();
    }catch (Exception e) {
        logger.error("set up server error:", e);
    }

Reply via email to