use of org.apache.sshd.server.auth.pubkey.UserAuthPublicKeyFactory in project jPOS by jpos.
the class SshService method startService.
@Override
protected void startService() throws Exception {
String username = cfg.get("auth-username", "admin");
String authorizedKeysFilename = cfg.get("authorized-keys-file", "cfg/authorized_keys");
String hostKeys = cfg.get("hostkeys-file", "cfg/hostkeys.ser");
int port = cfg.getInt("port", 2222);
checkAuthorizedKeys(authorizedKeysFilename);
String[] prefixes = getPrefixes();
sshd = SshServer.setUpDefaultServer();
sshd.setPort(port);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File(hostKeys).toPath()));
CliShellFactory csf = new CliShellFactory(getServer(), prefixes);
sshd.setShellFactory(csf);
sshd.setCommandFactory(csf);
sshd.setUserAuthFactories(Collections.singletonList(new UserAuthPublicKeyFactory()));
sshd.setPublickeyAuthenticator(new AuthorizedKeysFileBasedPKA(username, authorizedKeysFilename));
sshd.start();
log.info("Started SSHD @ port " + port);
}
use of org.apache.sshd.server.auth.pubkey.UserAuthPublicKeyFactory in project karaf by apache.
the class UserAuthFactoriesFactory method setAuthMethods.
public void setAuthMethods(String[] methods) {
this.methodSet = new HashSet<>();
this.factories = new ArrayList<>();
for (String am : methods) {
if (PASSWORD_METHOD.equals(am)) {
this.factories.add(new UserAuthPasswordFactory());
} else if (KEYBOARD_INTERACTIVE_METHOD.equals(am)) {
this.factories.add(new UserAuthKeyboardInteractiveFactory());
} else if (PUBLICKEY_METHOD.equals(am)) {
this.factories.add(new UserAuthPublicKeyFactory());
} else {
throw new IllegalArgumentException("Invalid authentication method " + am + " specified");
}
this.methodSet.add(am);
}
}
Aggregations