You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by 祝居旺 <zh...@aspirecn.com> on 2017/10/09 10:09:39 UTC

Emergency help ! ! !

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);
    }

Re: Emergency help ! ! !

Posted by elijah baley <e_...@outlook.com>.
Not clear what you are attempting to do - however, after calling sshServer.start() you need to "hang" - e.g

    sshServer.start();
    while (true) Thread.sleep(Long.MAX_VALUE);

________________________________
From: 祝居旺 <zh...@aspirecn.com>
Sent: Monday, October 9, 2017 1:09 PM
To: dev@mina.apache.org
Subject: Emergency help ! ! !

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);
    }