You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
keeping SSHAttributesBuilder, SSHDevice and TtyCommand delete the netty sub-package and use the following bridge class :
package org.aesh.terminal.ssh.mina;
import org.aesh.terminal.Connection;
import org.aesh.terminal.ssh.TtyCommand;
import org.aesh.terminal.telnet.util.Helper;
import org.apache.sshd.common.keyprovider.KeyPairProvider;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.auth.password.PasswordAuthenticator;
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
/**
* @author <a href="mailto:[email protected]">Julien Viet</a>
*/
public class SshTtyBootstrap {
private String host;
private int port;
private Charset charset;
private SshServer server;
private KeyPairProvider keyPairProvider;
private PasswordAuthenticator passwordAuthenticator;
private PublickeyAuthenticator publicKeyAuthenticator;
public SshTtyBootstrap() {
this.host = "localhost";
this.port = 5000;
this.charset = StandardCharsets.UTF_8;
this.keyPairProvider = new SimpleGeneratorHostKeyProvider(new File("hostkey.ser").toPath());
this.passwordAuthenticator = (username, password, session) -> true;
}
public String getHost() {
return host;
}
public SshTtyBootstrap setHost(String host) {
this.host = host;
return this;
}
public int getPort() {
return port;
}
public SshTtyBootstrap setPort(int port) {
this.port = port;
return this;
}
public SshTtyBootstrap setPasswordAuthenticator(PasswordAuthenticator passwordAuthenticator) {
this.passwordAuthenticator = passwordAuthenticator;
return this;
}
public SshTtyBootstrap setPublicKeyAuthenticator(PublickeyAuthenticator publicKeyAuthenticator) {
this.publicKeyAuthenticator = publicKeyAuthenticator;
return this;
}
public CompletableFuture<Void> start(Consumer<Connection> handler) throws Exception {
CompletableFuture<Void> fut = new CompletableFuture<>();
start(handler, Helper.startedHandler(fut));
return fut;
}
public KeyPairProvider getKeyPairProvider() {
return keyPairProvider;
}
public SshTtyBootstrap setKeyPairProvider(KeyPairProvider keyPairProvider) {
this.keyPairProvider = keyPairProvider;
return this;
}
public Charset getCharset() {
return charset;
}
public void setCharset(Charset charset) {
this.charset = charset;
}
public void start(Consumer<Connection> factory, Consumer<Throwable> doneHandler) {
server = SshServer.setUpDefaultServer();
server.setPort(port);
server.setHost(host);
server.setKeyPairProvider(keyPairProvider);
server.setPasswordAuthenticator(passwordAuthenticator);
if (publicKeyAuthenticator != null) {
server.setPublickeyAuthenticator(publicKeyAuthenticator);
}
server.setShellFactory((channelSession) -> new TtyCommand(charset, factory));
try {
server.start();
} catch (Exception e) {
doneHandler.accept(e);
return;
}
doneHandler.accept(null);
}
public CompletableFuture<Void> stop() throws InterruptedException {
CompletableFuture<Void> fut = new CompletableFuture<>();
stop(Helper.stoppedHandler(fut));
return fut;
}
public void stop(Consumer<Throwable> doneHandler) {
if (server != null) {
try {
server.stop();
} catch (IOException e) {
doneHandler.accept(e);
return;
}
doneHandler.accept(null);
} else {
doneHandler.accept(new IllegalStateException("Server not started"));
}
}
}
The text was updated successfully, but these errors were encountered:
terefang
changed the title
ssh support stuck at apache sshd 1.0 does interop with newer ssh clients
ssh support stuck at apache sshd 1.0 does not interop with newer ssh clients
Nov 19, 2019
keeping SSHAttributesBuilder, SSHDevice and TtyCommand delete the netty sub-package and use the following bridge class :
The text was updated successfully, but these errors were encountered: