Skip to content

Commit

Permalink
eclipse-ditto#985 limit supported ssh client authentication methods g…
Browse files Browse the repository at this point in the history
…lobally

Signed-off-by: Dominik Guggemos <dominik.guggemos@bosch.io>
  • Loading branch information
dguggemos committed Mar 25, 2021
1 parent 970dc9d commit dce01a4
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.apache.sshd.client.SshClient;
import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.auth.UserAuthMethodFactory;
import org.apache.sshd.common.session.SessionHeartbeatController;
import org.apache.sshd.core.CoreModuleProperties;
import org.apache.sshd.server.config.AllowTcpForwardingValue;
Expand Down Expand Up @@ -64,11 +65,14 @@ private SshClientProvider(final ActorSystem actorSystem) {
sshClient = SshClient.setUpDefaultClient();
// allow only local port forwarding
sshClient.setForwardingFilter(FORWARDING_FILTER);
// allow only public-key and password authentication
sshClient.setUserAuthFactoriesNames(UserAuthMethodFactory.PUBLIC_KEY, UserAuthMethodFactory.PASSWORD);

final long idleTimeoutMs = tunnelConfig.getIdleTimeout().toMillis();
PropertyResolverUtils.updateProperty(sshClient, CoreModuleProperties.IDLE_TIMEOUT.getName(), idleTimeoutMs);
LOGGER.debug("Configuring socket keepalive for ssh client: {}", tunnelConfig.getSocketKeepAlive());
PropertyResolverUtils.updateProperty(sshClient, CoreModuleProperties.SOCKET_KEEPALIVE.getName(), tunnelConfig.getSocketKeepAlive());
PropertyResolverUtils.updateProperty(sshClient, CoreModuleProperties.SOCKET_KEEPALIVE.getName(),
tunnelConfig.getSocketKeepAlive());

// TODO add more configuration?
if (tunnelConfig.getWorkers() > 0) {
Expand Down

0 comments on commit dce01a4

Please sign in to comment.