You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "chenss-1 (via GitHub)" <gi...@apache.org> on 2023/04/29 03:21:31 UTC
[GitHub] [mina-sshd] chenss-1 opened a new issue, #365: Can you write a example module ?
chenss-1 opened a new issue, #365:
URL: https://github.com/apache/mina-sshd/issues/365
### Description
I want to use sshd to deploy a sftpserver ,but can't find a example .where I can find a easy demo?
### Motivation
for easy use
### Alternatives considered
_No response_
### Additional context
_No response_
--
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: dev-unsubscribe@mina.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
[GitHub] [mina-sshd] tomaswolf closed issue #365: Can you write a example module ?
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf closed issue #365: Can you write a example module ?
URL: https://github.com/apache/mina-sshd/issues/365
--
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: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
[GitHub] [mina-sshd] chenss-1 commented on issue #365: Can you write a example module ?
Posted by "chenss-1 (via GitHub)" <gi...@apache.org>.
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: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
[GitHub] [mina-sshd] tomaswolf commented on issue #365: Can you write a example module ?
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on issue #365:
URL: https://github.com/apache/mina-sshd/issues/365#issuecomment-1532143770
Looks like you answered your own question. Congratulations!
--
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: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org