我已經從here下載並共享了Apache Mina base FTP服務器。 我可以使用FTP連接。Apache Mina FTP服務器SFTP配置和使用FileZiza或WInscp或任何FTP客戶端連接SFTP連接接管了安全通道
當我試圖配置SFTP與下面的配置我得到錯誤,當我嘗試使用FIleZila或任何其他客戶端的SFTP連接。
服務器配置:下面
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://mina.apache.org/ftpserver/spring/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
id="myServer">
<listeners>
<nio-listener name="default" port="2222" implicit-ssl="true" idle-timeout="60">
<ssl>
<keystore file="mykeystore.jks" password="ftpkey" key-password="ftpkey" />
</ssl>
</nio-listener>
</listeners>
<!--<file-user-manager file="users.properties"
encrypt-passwords="true" />-->
是我使用生成證書命令:
keytool -genkey -alias ftpkeya -keysize 1024 -dname "cn=mydomain.com,o=mycompany,ou=company,l=Capelle,s=NL,c=NL" -keystore mykeystore.jks -keypass ftpkey -storepass ftpkey -keyalg RSA
keytool -list -keystore mykeystore.jks -storepass ftpkey -v
keytool -export -alias ftpkeya -keystore mykeystore.jks -storepass ftpkey -file serverCertificate.arm -rfc
我使用keytool生成keysore和證書。當我生成證書,並在上述服務器配置配置我的服務器啓動與SFTP支持,但當我試圖連接使用FTP客戶端連接被拒絕,
我收到不同的異常在我的服務器日誌與不同的FTP客戶端:
當我使用WinScp時,異常服務器異常日誌。
[ WARN] 2017-05-08 09:49:16,018 [] [0:0:0:0:0:0:0:1] EXCEPTION :
org.apache.mina.core.write.WriteToClosedSessionException
at org.apache.mina.core.polling.AbstractPollingIoProcessor.clearWriteRequestQueue(AbstractPollingIoProcessor.java:641)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.removeNow(AbstractPollingIoProcessor.java:592)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.removeSessions(AbstractPollingIoProcessor.java:562)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$800(AbstractPollingIoProcessor.java:68)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1149)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[ WARN] 2017-05-08 09:49:16,019 [] [0:0:0:0:0:0:0:1] Client closed connection before all replies could be sent, last reply was WriteRequest: HeapBuffer[pos=0 lim=20 cap=20: 35 33 30 20 41 63 63 65 73 73 20 64 65 6E 69 65...]
[ INFO] 2017-05-08 09:49:16,019 [] [0:0:0:0:0:0:0:1] CLOSED
而不同的更多的時候我使用filezila。
客戶端日誌:
Status: Waiting to retry...
Status: Connecting to 172.27.136.44:2222...
Response: fzSftp started, protocol_version=8
Command: open "[email protected]" 2222
Error: Network error: Connection refused
Error: Could not connect to server
服務器端日誌,同時從FileZilla中連接
[ WARN] 2017-05-08 09:42:45,913 [] [172.27.136.44] EXCEPTION :
java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:197)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
at org.apache.mina.transport.socket.nio.NioProcessor.read(NioProcessor.java:280)
at org.apache.mina.transport.socket.nio.NioProcessor.read(NioProcessor.java:44)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:695)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:668)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:657)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:68)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1141)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[ERROR] 2017-05-08 09:42:45,916 [] [172.27.136.44] Exception caught, closing session
java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.SocketDispatcher.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:197)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
at org.apache.mina.transport.socket.nio.NioProcessor.read(NioProcessor.java:280)
at org.apache.mina.transport.socket.nio.NioProcessor.read(NioProcessor.java:44)
我期待有不應該在服務器日誌任何區別,而從任何連接FTP客戶端我不明白爲什麼,這裏有什麼問題。我已經提到這link.
在此先感謝您的任何形式的幫助和信息。
向我們顯示客戶端日誌。 –
已添加客戶端filezilla日誌。我不知道我可以獲取winscp日誌的位置。 –
日誌只是確認我的答案。 - 您正在使用SFTP協議連接到FTP(S)服務器。這是行不通的。在客戶端使用FTP(S) - 或者如果您確實需要實現SFTP服務器,那麼您將處於完全錯誤的軌道上。 –