AbstractGeneratorHostKeyProvider hostKeyProvider = new SimpleGeneratorHostKeyProvider(SERVER_KEY_FILE.toPath()); hostKeyProvider.setAlgorithm("RSA"); sshd.setKeyPairProvider(hostKeyProvider);
protected void setupKeyPair() { final AbstractGeneratorHostKeyProvider provider; if (SecurityUtils.isBouncyCastleRegistered()) { provider = SecurityUtils.createGeneratorHostKeyProvider(new File(HOSTKEY_FILE_PEM).toPath()); } else { provider = new SimpleGeneratorHostKeyProvider(new File(HOSTKEY_FILE_SER)); } provider.setAlgorithm(KeyUtils.RSA_ALGORITHM); sshd.setKeyPairProvider(provider); }
public static SshServer create() { SshServer sshd = SshServer.setUpDefaultServer(); sshd.setPort(SpashConfig.getInstance().spashListenPort()); AbstractGeneratorHostKeyProvider keyProvider = new SimpleGeneratorHostKeyProvider(new File(SpashConfig.getInstance().spashKeyFileName())); keyProvider.setAlgorithm(SpashConfig.getInstance().spashKeyAlgorithm()); keyProvider.setKeySize(SpashConfig.getInstance().spashKeyLength()); sshd.setKeyPairProvider(keyProvider); List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>(); userAuthFactories.add(new UserAuthPasswordFactory()); sshd.setUserAuthFactories(userAuthFactories); sshd.setPasswordAuthenticator(new PasswordAuthenticator() { @Override public boolean authenticate(String username, String password, ServerSession serverSession) throws PasswordChangeRequiredException { return username!=null && username.length()>0 && username.equals(password); } }); sshd.setShellFactory(new SpashShellFactory()); List<NamedFactory<Command>> namedFactoryList = new ArrayList<>(); namedFactoryList.add(new SftpSubsystemFactory()); sshd.setSubsystemFactories(namedFactoryList); sshd.setCommandFactory(new ScpCommandFactory()); sshd.setFileSystemFactory(new FileSystemFactory() { @Override public FileSystem createFileSystem(Session session) throws IOException { return SpashFileSystem.get().getFileSystem(); } }); return sshd; }
keyPairProvider.setAlgorithm(algorithm); } catch (final Exception ignore) { throw new RuntimeException(String.format("Can't use '%s' algorithm for ssh key pair generator.",