Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SFTP via JSch is throwing error 4: Failure

I am facing a peculiar issue while trying to SFTP a file from Windows to Unix server. The error "stack trace" is -

4: Failure
    at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2846)
    at com.jcraft.jsch.ChannelSftp.checkStatus(ChannelSftp.java:2459)
    at com.jcraft.jsch.ChannelSftp._sendCLOSE(ChannelSftp.java:2465)
    at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:683)
    at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:475)
    at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:365)

I have searched a lot on other forums but could not get to the root cause. I have observed one more thing - the file name, I am trying to SFTP, is *.xml when I change it to *.XML the SFTP is "successful". Very weird could not identify the issue. I am trying this using JSch Java API. But I have seen the same issue while trying the WinSCP front end.

like image 747
Saikat Avatar asked Nov 13 '14 07:11

Saikat


People also ask

What is JSch in SFTP?

Use the JSch library JSch is a Java implementation for the SSH2 protocol. It allows you to connect to an OpenSSH server through the sshd process and use secure file transferring. In addition, it also allows you to use port forwarding and X11 forwarding. JSch supports SSH File Transfer Protocol(version 0, 1, 2, 3).


1 Answers

It is common for OpenSSH SFTP server to return code 4 (Failure) for many different reasons, without giving any details.

You would have to check SFTP server log to find more.

Though the most usual cause is a lack of free disk or user quota space – Which can usually be identified by the file being created with zero size.

like image 134
Martin Prikryl Avatar answered Sep 30 '22 14:09

Martin Prikryl