V1.0.1 Log remote login password

master
Ng Yat Yan 1 month ago
parent a4aec058a1
commit 61e15af8d4

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.example.sshd</groupId> <groupId>com.example.sshd</groupId>
<artifactId>echo-sshd-server</artifactId> <artifactId>echo-sshd-server</artifactId>
<version>1.0.0</version> <version>1.0.1</version>
<name>ECHO SSH SERVER</name> <name>ECHO SSH SERVER</name>
<description>Learning Apache Mina SSHD library</description> <description>Learning Apache Mina SSHD library</description>
<parent> <parent>

@ -9,6 +9,8 @@ import org.apache.sshd.SshServer;
import org.apache.sshd.server.PasswordAuthenticator; import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.session.ServerSession; import org.apache.sshd.server.session.ServerSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -16,6 +18,8 @@ import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
public class SshConfig { public class SshConfig {
private static final Logger logger = LoggerFactory.getLogger(SshConfig.class);
@Value("${ssh-server.port}") @Value("${ssh-server.port}")
private int port; private int port;
@ -34,6 +38,7 @@ public class SshConfig {
sshd.setPasswordAuthenticator(new PasswordAuthenticator() { sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
@Override @Override
public boolean authenticate(final String username, final String password, final ServerSession session) { public boolean authenticate(final String username, final String password, final ServerSession session) {
logger.info("Login Attempt: username = {}, password = {}", username, password);
return StringUtils.equals(username, rootUsername); return StringUtils.equals(username, rootUsername);
} }
}); });

Loading…
Cancel
Save