chenss-1 commented on issue #365:
URL: https://github.com/apache/mina-sshd/issues/365#issuecomment-1528647804
I test a success demo!!!!
` private SshServer sshd;
private final static Logger logger =
LoggerFactory.getLogger(SftpServer.class);
public void start() {
sshd = SshServer.setUpDefaultServer();
sshd.setPort(11230);
sshd.setHost("localhost");
SftpSubsystemFactory factory = new
SftpSubsystemFactory.Builder().build();
sshd.setPasswordAuthenticator(new MyPasswordAuthenticator());
sshd.setPublickeyAuthenticator(DefaultAuthorizedKeysAuthenticator.INSTANCE);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
sshd.setSubsystemFactories(Collections.singletonList(factory));
sshd.setCommandFactory(new ScpCommandFactory());
sshd.setFileSystemFactory(new
VirtualFileSystemFactory(Paths.get("E:/root")));
try {
logger.info("Starting ...");
sshd.start();
System.out.println("started");
logger.info("Started");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.info("Can not Start Server");
}
while (true){
}
}
public static void main(String[] args) {
SftpServer sftpServer = new SftpServer();
sftpServer.start();
}`
`public class MyPasswordAuthenticator implements PasswordAuthenticator {
@Override
public boolean authenticate(String username, String password,
ServerSession session)
throws PasswordChangeRequiredException, AsyncAuthException {
// TODOļ¼ change your username
// for Test
if (username.equals("<your user>")){
return true;
}
return false;
}
}`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]