Я использую Apache Mina sshd-core-1.0.0 для запуска SFTP-демона. Однако программа выходит после sshd.start()
. Ошибок нет. Однако, если я использую sshd-core-0.0.14, сервер начинает работать нормально, и я могу инициировать сеанс SFTP. Я что-то пропустил с 1.0.0?Apache Mina SSHD 1.0 Сервер немедленно выходит
Фрагмент кода с версии 1.0.0 (не работает)
public static void main(String[] args) throws IOException {
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(2222);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File ("hostkey.ser")))
sshd.setPasswordAuthenticator(new AuthenticatorImpl());
sshd.start();
}
Фрагмент кода с 0.0.14 (работ)
public static void main(String[] args) throws IOException {
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(2222);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));
sshd.setPasswordAuthenticator(new AuthenticatorImpl());
sshd.start();
}
Ниже выводится, когда 1.0.0 работает. Код начинается нормально, но завершается после инструкции sshd.start()
.
2015-12-16 19:57:38,510 DEBUG SFTPServer.main(SFTPServer.java:26) message
2015-12-16 19:57:38,767 INFO org.apache.sshd.common.util.SecurityUtils$BouncyCastleRegistration.call(SecurityUtils.java:145) Trying to register BouncyCastle as a JCE provider
2015-12-16 19:57:39,076 INFO org.apache.sshd.common.util.SecurityUtils$BouncyCastleRegistration.call(SecurityUtils.java:149) Registration succeeded
2015-12-16 19:57:39,105 DEBUG org.apache.sshd.common.io.nio2.Nio2Acceptor.bind(Nio2Acceptor.java:57) Binding Nio2Acceptor to address 0.0.0.0/0.0.0.0:2222
2015-12-16 19:57:39,114 INFO SFTPServer.main(SFTPServer.java:32) Started
Спасибо, что работает. – Rocky
Это решение полностью нарушает любые интеграционные тесты, которые вы, возможно, захотите запустить в своем приложении. – christopher