Package org.apache.sshd.client.channel

Examples of org.apache.sshd.client.channel.ChannelShell


        SshClient client1 = SshClient.setUpDefaultClient();
        client1.setAgentFactory(localAgentFactory);
        client1.start();
        ClientSession session1 = client1.connect("localhost", port1).await().getSession();
        assertTrue(session1.authAgent("smx").await().isSuccess());
        ChannelShell channel1 = session1.createShellChannel();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayOutputStream err = new ByteArrayOutputStream();
        channel1.setOut(out);
        channel1.setErr(err);
        channel1.setAgentForwarding(true);
        channel1.open().await();
        OutputStream pipedIn = channel1.getInvertedIn();

        synchronized (shellFactory.shell) {
            System.out.println("Possibly waiting for remote shell to start");
            if (!shellFactory.shell.started) {
                shellFactory.shell.wait();
            }
        }

        SshClient client2 = SshClient.setUpDefaultClient();
        client2.setAgentFactory(agentFactory);
        client2.getProperties().putAll(shellFactory.shell.getEnvironment().getEnv());
        client2.start();
        ClientSession session2 = client2.connect("localhost", port2).await().getSession();
        assertTrue(session2.authAgent("smx").await().isSuccess());
        ChannelShell channel2 = session2.createShellChannel();
        channel2.setIn(shellFactory.shell.getIn());
        channel2.setOut(shellFactory.shell.getOut());
        channel2.setErr(shellFactory.shell.getErr());
        channel2.setAgentForwarding(true);
        channel2.open().await();

        pipedIn.write("foo\n".getBytes());
        pipedIn.flush();

        Thread.sleep(1000);
View Full Code Here


        client = SshClient.setUpDefaultClient();
        client.start();
        ClientSession s = client.connect("localhost", port).await().getSession();
        s.authPassword("test", "test").await();
        ChannelShell shell = s.createShellChannel();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayOutputStream err = new ByteArrayOutputStream();
        shell.setOut(out);
        shell.setErr(err);
        shell.open().await();
        int res = s.waitFor(ClientSession.CLOSED, 5000);
        assertTrue((res & ClientSession.CLOSED) != 0);
        assertTrue(latch.await(1, TimeUnit.SECONDS));
        assertTrue(TestEchoShellFactory.TestEchoShell.latch.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

    //
    ClientSession session = client.connect("localhost", port).await().getSession();
    session.authPassword("root", "");

    //
    ChannelShell channel = (ChannelShell)session.createShellChannel();
    channel.setPtyModes(tty);

    //
    PipedOutputStream out = new PipedOutputStream();
    PipedInputStream channelIn = new PipedInputStream(out);

    //
    PipedOutputStream channelOut = new PipedOutputStream();
    PipedInputStream in = new PipedInputStream(channelOut);

    //
    channel.setIn(channelIn);
    channel.setOut(channelOut);
    channel.setErr(new ByteArrayOutputStream());
    channel.open();

    //
    this.channel = channel;
    this.client = client;
    this.session = session;
View Full Code Here

TOP

Related Classes of org.apache.sshd.client.channel.ChannelShell

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.