public void setupSftpServer(){ SshServer sshd = SshServer.setUpDefaultServer(); sshd.setPort(22); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>(); userAuthFactories.add(new UserAuthNone.Factory()); sshd.setUserAuthFactories(userAuthFactories); sshd.setCommandFactory(new ScpCommandFactory()); List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>(); namedFactoryList.add(new SftpSubsystem.Factory()); sshd.setSubsystemFactories(namedFactoryList); try { sshd.start(); } catch (Exception e) { e.printStackTrace(); } }
server.setCommandFactory(new SCPCommandFactory(context)); server.setKeyPairProvider(keyPairProvider);
public static SshServer setUpDefaultServer(final SshdConfigInterface configInterface) { SshServer sshd = SshServer.setUpDefaultServer(); sshd.setCommandFactory(new PrtgCommandFactory(configInterface)); sshd.setShellFactory(new PrtgShellFactory(configInterface)); return sshd; }
sshServer.setPort(2222); sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("my.pem").getAbsolutePath())); sshServer.setCommandFactory(new ScpCommandFactory()); List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<>(); userAuthFactories.add(new UserAuthPassword.Factory());
sshd.setCommandFactory(new ScpCommandFactory(myCommandFactory)); List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>(); namedFactoryList.add(new SftpSubsystem.Factory());
sshServer.setCommandFactory(new CommandFactory() { @Override public Command createCommand(String command) {
sshServer.setCommandFactory(new CommandFactory() { @Override public Command createCommand(String command) {
@Override public void initialize(int port) { Security.addProvider(new BouncyCastleProvider()); sshd = SshServer.setUpDefaultServer(); sshd.setPort(port); StreamKeyPairProvider fileKeyPairProvider = new StreamKeyPairProvider(); sshd.setKeyPairProvider(fileKeyPairProvider); SftpSubsystem.Factory factory = new SftpSubsystem.Factory(); sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(factory)); sshd.setCommandFactory(new ScpCommandFactory()); sshd.setShellFactory(new ProcessShellFactory()); sshd.setPasswordAuthenticator(new MockPasswordAuthenticator()); }
sshd.setSubsystemFactories(Arrays .<NamedFactory<Command>> asList(new SftpSubsystem.Factory())); sshd.setCommandFactory(new ScpCommandFactory()); sshd.setShellFactory(new ProcessShellFactory(new String[] { "/system/bin/sh", "-i", "-l" })); // necessary if you want to type commands over ssh sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
public void startSSHServer() { int port = 8888; SshServer sshd = SshServer.setUpDefaultServer(); sshd.setPort(port); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider( "src/test/resources/hostkey.ser")); sshd.setSubsystemFactories(Arrays .<NamedFactory<Command>> asList(new SftpSubsystem.Factory())); sshd.setCommandFactory(new ScpCommandFactory()); sshd.setShellFactory(new ProcessShellFactory(new String[] { "/system/bin/sh", "-i", "-l" })); // necessary if you want to type commands over ssh sshd.setPasswordAuthenticator(new PasswordAuthenticator() { @Override public boolean authenticate(String u, String p, ServerSession s) { return ("sftptest".equals(u) && "sftptest".equals(p)); } }); try { sshd.start(); } catch (IOException e) { e.printStackTrace(); } }
void init(Context context, Device device) throws Exception { sshd.setKeyExchangeFactories(Arrays.asList( new DHG14.Factory(), new DHG1.Factory())); //Reuse this device keys for the ssh connection as well final KeyPair keyPair; PrivateKey privateKey = RsaHelper.getPrivateKey(context); PublicKey publicKey = RsaHelper.getPublicKey(context); keyPair = new KeyPair(publicKey, privateKey); sshd.setKeyPairProvider(new AbstractKeyPairProvider() { @Override public Iterable<KeyPair> loadKeys() { return Collections.singletonList(keyPair); } }); sshd.setFileSystemFactory(new AndroidFileSystemFactory(context)); sshd.setCommandFactory(new ScpCommandFactory()); sshd.setSubsystemFactories(Collections.singletonList(new SftpSubsystem.Factory())); if (device.publicKey != null) { keyAuth.deviceKey = device.publicKey; } else { keyAuth.deviceKey = device.certificate.getPublicKey(); } sshd.setPublickeyAuthenticator(keyAuth); sshd.setPasswordAuthenticator(passwordAuth); }
server.setCommandFactory(new SCPCommandFactory(context)); server.setKeyPairProvider(keyPairProvider);
server.setCommandFactory(new SCPCommandFactory(getContext())); server.setKeyPairProvider(new URLKeyPairProvider(key));
/** * Starts a ssh server on the provided port. * * @param server the server mock to start * * @return the server. * @throws IOException if so. */ public static SshServer startServer(SshdServerMock server) throws IOException { SshServer sshd = SshServer.setUpDefaultServer(); sshd.setPort(0); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); List<NamedFactory<UserAuth>>userAuthFactories = new ArrayList<NamedFactory<UserAuth>>(); userAuthFactories.add(new UserAuthNone.Factory()); sshd.setUserAuthFactories(userAuthFactories); sshd.setCommandFactory(server); sshd.start(); return sshd; }
sshd.setCommandFactory( commandFactory );
sshd.setCommandFactory( commandFactory );
sshServer.setCommandFactory(new ScpCommandFactory()); List<NamedFactory<Command>> factoryList = new ArrayList<>(1); factoryList.add(new SftpSubsystem.Factory());
Server.setCommandFactory(new ScpCommandFactory(new TestCommandFactory()));
Server.setCommandFactory(new ScpCommandFactory(new TestCommandFactory()));
Server.setCommandFactory(new ScpCommandFactory(new TestCommandFactory()));