2
我已經安裝的Apache米娜SSHD SFTP服務器,我添加一些用戶權限到it.To測試我使用WINSCP但我可以帶出服務器連接輸入正確的密碼和用戶name.It好像SetPasswordAuthenticator方法不會called.So我想知道如何爲啓動我的Apache米娜sshd的SFTP服務器,我設置了用戶名和密碼了安全服務器。阿帕奇米娜SSHD SetPasswordAuthenticator不執行
我的服務器代碼,
sshd = SshServer.setUpDefaultServer();
sshd.setPort(2525);
sshd.setHost("172.xx.xx.xx");
sshd.setPasswordAuthenticator(new MyPasswordAuthenticator());
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>> asList(new SftpSubsystem.Factory()));
List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>();
userAuthFactories.add(new UserAuthNone.Factory());
sshd.setUserAuthFactories(userAuthFactories);
sshd.setCommandFactory(new ScpCommandFactory());
sshd.setKeyExchangeFactories(Arrays
.<NamedFactory<KeyExchange>> asList(new DHG1.Factory()));
sshd.setCommandFactory(new ScpCommandFactory());
sshd.setFileSystemFactory(new VirtualFileSystemFactory("C:/root"));
MyPasswordAuthenticator代碼,
public class MyPasswordAuthenticator implements PasswordAuthenticator {
public boolean authenticate(String username, String password, ServerSession session) {
boolean retour = false;
if ("user".equals(username) && "123".equals(password)) {
retour = true;
}
return retour;
}
}
Maven的依賴,
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-sftp</artifactId>
<version>0.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>0.14.0</version>
</dependency>
我是新來的Apache米娜Sshd.Appreciate任何 幫幫我。