Background
- Server information:
Server a:10.102.110.1
Server b:10.102.110.2
You need to transfer files from server A to Server B via SFTP.
Application project has a function, to pass the SFTP log file transfer, at the time of deployment, the server has been configured for authentication-free (secret), but also the SFTP password-free login, but after the project is deployed, start the service, when the need to transfer or reported the following error:
com.jcraft.jsch.JSchException: Auth fail
14:26:12.704 [pool-1-thread-1] ERROR filetransfer-connect to server Failed:com.jcraft.jsch.JSchException:Auth fail a T Com.jcraft.jsch.Session.connect (session.java:519) ~[jsch-0.1.54.jar:na] at Com.jcraft.jsch.Session.connect ( session.java:183) ~[jsch-0.1.54.jar:na] at Com.shop.core.log.transfer.SftpFileTransfer.connect ( sftpfiletransfer.java:64) ~[livechat-core-0.0.1-snapshot.jar:na] at Com.shop.core.log.transfer.FileTransferExecutor.processFile (filetransferexecutor.java:96) [ Livechat-core-0.0.1-snapshot.jar:na] at com.shop.core.log.transfer.filetransferexecutor.access$000 ( FILETRANSFEREXECUTOR.JAVA:26) [Livechat-core-0.0.1-snapshot.jar:na] at Com.shop.core.log.transfer.filetransferexecutor$1.run (filetransferexecutor.java:48) [ Livechat-core-0.0.1-snapshot.jar:na] at Java.util.concurrent.executors$runnableadapter.call (Executors.java:471) [ NA:1.7.0_67] at Java.util.concurrent.FutureTask.runAndReset (futuretask.java:304) [na:1.7.0_67] at Java.util.concurr Ent. Scheduledthreadpoolexecutor$scheduledfuturetask.access$301 (scheduledthreadpoolexecutor.java:178) [na:1.7.0_67] at Java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.run (scheduledthreadpoolexecutor.java:293) [na:1.7.0_67] at Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1145) [na:1.7.0_67] at J Ava.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:615) [na:1.7.0_67] at Java.lang.Thread.run (thread.java:745) [na:1.7.0_67]14:26:12.705 [pool-1-thread-1] ERROR Filetransfer-connect to 10.102.110.7 failed, cannot transfer data files!14:26:22.768 [pool-1-thread-1] ERROR filetransfer-connect to server fail Ed:com.jcraft.jsch.JSchException:Auth fail at Com.jcraft.jsch.Session.connect (session.java:519) ~[jsch-0.1.54.jar: NA] at Com.jcraft.jsch.Session.connect (session.java:183) ~[jsch-0.1.54.jar:na] at Com.shop.core.log.transfer.SftpFi Letransfer.connect (sftpfiletransfer.java:64) ~[livechat-core-0.0.1-snapshot.jar:nA] at Com.shop.core.log.transfer.FileTransferExecutor.processFile (filetransferexecutor.java:96) [ Livechat-core-0.0.1-snapshot.jar:na] at com.shop.core.log.transfer.filetransferexecutor.access$000 ( FILETRANSFEREXECUTOR.JAVA:26) [Livechat-core-0.0.1-snapshot.jar:na] at Com.shop.core.log.transfer.filetransferexecutor$1.run (filetransferexecutor.java:48) [ Livechat-core-0.0.1-snapshot.jar:na] at Java.util.concurrent.executors$runnableadapter.call (Executors.java:471) [ NA:1.7.0_67] at Java.util.concurrent.FutureTask.runAndReset (futuretask.java:304) [na:1.7.0_67] at Java.util.concurr Ent. scheduledthreadpoolexecutor$scheduledfuturetask.access$301 (scheduledthreadpoolexecutor.java:178) [na:1.7.0_67] At Java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.run (Scheduledthreadpoolexecutor.java : 293) [na:1.7.0_67] at Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1145) [na:1.7.0_ +] at Java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) [na:1.7.0_67] at Java.lang.Thread.run (thread.java:745) [na:1.7.0_67]14:26:22.768 [pool-1-thread-1] ERROR Filetransfer-connect to 10.102.110.7 failed, cannot transfer data files!
Resolution procedure 1, check configuration parameters such as user name and password configuration errors
Do not make too much explanation here, to check the configuration of the SFTP connection is correct.
2, check the server between the SFTP non-secret login configuration is OK
Encounter Auth fail
authentication failure, then the first to troubleshoot is the server's SSH password-free login configuration is OK, 10.102.110.1 Server A through the following command:
SSH [email protected]
- Shop: User Name
- 10.102.110.2: Server IP
After you enter a command, you do not need to enter a password to connect to Server B successfully. That means no-secret configuration is ok!
3. Check Configuration Items
PasswordAuthentication
A configuration item in the/etc/ssh/sshd_config folder passwordauthentication default to No!
"Passwordauthentication" set whether to allow password authentication, change it to Yes, restart the service OK.
I looked at the 10.102.110.2 Server B configuration and found no problems. Passwordauthentication is configured with Yes.
4, see if Session.connect set the connection timeout
View Code Discovery Code, connect as the default construct.
//省略其他代码this.sshSession.connect();//省略其他代码
Look at the source, think this connection timeout to set, the default is 0!
Then change to the following code
// 设置登陆超时时间,不设置可能会报错this.sshSession.connect(1500);
Restart the service, found normal, can connect successfully, also reported wrong.
Summarize
The emergence of a problem, there may be a lot of reasons, not because the problem arose and disorderly hands and feet, to have the idea of troubleshooting problems, step by step, the final problem will be resolved.
Reference
Jsch Connection to SFTP Service error: Auth fail
If you think this blog is helpful to you, please praise or like, let more people see, thank you!
If handsome (beautiful), Wise (Smart), and I as simple and good you see this blog post there are problems, please point out, I humbly accept you let me grow criticism, thank you for reading!
I wish you a happy day!
Welcome to visit my csdn blog, we grow together!
No matter what you do, just stick to it and see it differently! On the way, decently!
Blog home: http://blog.csdn.net/u010648555
? A punk who's getting better every day.
Com.jcraft.jsch.JSchException:Auth fail