We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.11.0
package cn.dyw.web.jshell.client; import org.apache.sshd.client.SshClient; import org.apache.sshd.client.channel.ClientChannel; import org.apache.sshd.client.channel.ClientChannelEvent; import org.apache.sshd.client.future.ConnectFuture; import org.apache.sshd.client.session.ClientSession; import org.apache.sshd.common.future.CancelOption; import org.apache.sshd.common.util.io.input.NoCloseInputStream; import org.apache.sshd.common.util.io.output.NoCloseOutputStream; import org.junit.jupiter.api.Test; import java.net.InetSocketAddress; import java.util.Collections; import java.util.concurrent.TimeUnit; /** * @author dyw770 * @date 2023-11-27 */ public class SSHDClientTest { /** * Server has no output */ @Test public void testSSHDClient() throws Exception { SshClient client = SshClient.setUpDefaultClient(); client.start(); ConnectFuture connectFuture = client.connect("root", new InetSocketAddress("172.16.253.101", 22)); ClientSession session = connectFuture.verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT).getSession(); session.addPasswordIdentity("123456789"); session.auth().verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT); ClientChannel channel =session.createShellChannel(); channel.setOut(new NoCloseOutputStream(System.out)); channel.setRedirectErrorStream(true); channel.setIn(new NoCloseInputStream(System.in)); channel.open().verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT); channel.waitFor(Collections.singleton(ClientChannelEvent.CLOSED), 0); channel.close(); session.close(); client.stop(); } /** * Normal server output */ public static void main(String[] args) throws Exception { SshClient client = SshClient.setUpDefaultClient(); client.start(); ConnectFuture connectFuture = client.connect("root", new InetSocketAddress("172.16.253.101", 22)); ClientSession session = connectFuture.verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT).getSession(); session.addPasswordIdentity("123456789"); session.auth().verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT); ClientChannel channel =session.createShellChannel(); channel.setOut(new NoCloseOutputStream(System.out)); channel.setRedirectErrorStream(true); channel.setIn(new NoCloseInputStream(System.in)); channel.open().verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT); channel.waitFor(Collections.singleton(ClientChannelEvent.CLOSED), 0); channel.close(); session.close(); client.stop(); } }
The result is shown in the figure
Can you tell me where my mistake lies? Thinks.
Server has no output
Normal server output
No response
The text was updated successfully, but these errors were encountered:
Cannot reproduce. Using your code on OS X with two minor modifications:
Both running main or running the unit test work, ls or ls -l do show the expected output.
main
ls
ls -l
Sorry, something went wrong.
Cannot reproduce. Using your code on OS X with two minor modifications: Connect to my own user on localhost port 22. Use public-key authentication instead of password authentication. Both running main or running the unit test work, ls or ls -l do show the expected output.
Thank, I think I need to check my ide.
Idea needs to add -Deditable.java.test.console=true options
-Deditable.java.test.console=true
No branches or pull requests
Version
2.11.0
Bug description
The result is shown in the figure
Can you tell me where my mistake lies?
Thinks.
Actual behavior
Server has no output
Expected behavior
Normal server output
Relevant log output
No response
Other information
No response
The text was updated successfully, but these errors were encountered: