From 61e15af8d44a15d2d802475eaa7c8a7e282a2ab0 Mon Sep 17 00:00:00 2001 From: Ng Yat Yan Date: Sat, 12 Oct 2024 09:44:56 +0800 Subject: [PATCH] V1.0.1 Log remote login password --- pom.xml | 2 +- src/main/java/com/example/sshd/config/SshConfig.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9b71dae..94c531f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.example.sshd echo-sshd-server - 1.0.0 + 1.0.1 ECHO SSH SERVER Learning Apache Mina SSHD library diff --git a/src/main/java/com/example/sshd/config/SshConfig.java b/src/main/java/com/example/sshd/config/SshConfig.java index f2ff6b0..be51a98 100644 --- a/src/main/java/com/example/sshd/config/SshConfig.java +++ b/src/main/java/com/example/sshd/config/SshConfig.java @@ -9,6 +9,8 @@ import org.apache.sshd.SshServer; import org.apache.sshd.server.PasswordAuthenticator; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; 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.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -16,6 +18,8 @@ import org.springframework.context.annotation.Configuration; @Configuration public class SshConfig { + private static final Logger logger = LoggerFactory.getLogger(SshConfig.class); + @Value("${ssh-server.port}") private int port; @@ -34,6 +38,7 @@ public class SshConfig { sshd.setPasswordAuthenticator(new PasswordAuthenticator() { @Override 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); } });