Tôi đang sử dụng ví dụ này, lấy từ Java SFTP Server Library?:SFTP máy chủ thiết lập người dùng/mật khẩu trong Apache Mina sshd
public void setupSftpServer(){
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(22);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));
List<NamedFactory<UserAuth>> userAuthFactories = new ArrayList<NamedFactory<UserAuth>>();
userAuthFactories.add(new UserAuthNone.Factory());
sshd.setUserAuthFactories(userAuthFactories);
sshd.setCommandFactory(new ScpCommandFactory());
List<NamedFactory<Command>> namedFactoryList = new ArrayList<NamedFactory<Command>>();
namedFactoryList.add(new SftpSubsystem.Factory());
sshd.setSubsystemFactories(namedFactoryList);
try {
sshd.start();
} catch (Exception e) {
e.printStackTrace();
}
}
Nhưng tôi cần phải đặt người dùng đăng nhập và pw cho máy chủ SFTP. Tôi có thể làm cái này như thế nào? Cảm ơn
bạn có may mắn không? Nó thiếu tài liệu. Xin hãy giúp tôi chia sẻ kinh nghiệm của bạn. –
Không may mắn, vẫn đang chờ phản hồi. – Alvins
tôi đã tạo câu trả lời, có thể nó có thể giúp bạn: http://stackoverflow.com/questions/18694108/apache-mina-sshd-problems-with-authentication-method-when-connecting-to-server/21553897#21553897 – Chris