Hello

I'm connection sshd to my shell service by doing

sshd.setShellFactory(new Factory<Command>() {

            @Override
            public Command create() {

                return new Command() {

                    @Override
                    public void start(Environment e) throws IOException {
                                    shell = shellFactory.createShell(in,
out);
                                    shell.addTerminationListener(new
Shell.TerminationListener() {
                                        public void terminated() {
                                            try {
                                                log.info("closing ssh
stream");
                                                out.close();
                                                in.close();
                                            } catch (IOException ex) {
                                                log.warn("error closing ssh
stream", ex);
                                            }
                                        };
                                    });
                                    shell.start();
                    }


Unfortunately closing in and out doesn't close the connection instantly,
only when the user of the ssh client presses a character I get a
"java.io.IOException: Pipe closed" and the connection is closed.

What's the right way to close the connection to a client?

Cheers,
Reto

Reply via email to