Archana Seetharam
Archana Seetharam

Reputation: 31

3: Permission denied. at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2846)

We have a java code which connects to a destination server and places multiple files in the destination folder. But when it places the first file and comes back to place the second file it gives the following error.

INFO: Next authentication method: keyboard-interactive INFO: Authentication succeeded (keyboard-interactive). 3: Permission denied. at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2846) at com.jcraft.jsch.ChannelSftp._put(ChannelSftp.java:594) at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:475) at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:365) at TravelFTPUpload.main(TravelFTPUpload.java:103) INFO: Disconnecting from 12.10.219.115 port 22 INFO: Caught an exception, leaving main loop due to Socket closed

Java code snippet:

for (int j = 0; j < listFiles.length; j++) 
{
    fN = listFiles[j].getAbsolutePath();
    destFn = listFiles[j].getName();
    fileNameList.append(destFn+"<br />");

    // Ex:GS2-20141128
    sftpChannel.put(fN, destFn);

}

Can someone please help me with this error. Note: The code works fine while connecting to a different destination folder.

Upvotes: 2

Views: 13318

Answers (2)

Ronald Coarite
Ronald Coarite

Reputation: 4746

Be sure to indicate the working directory in the channel

Use channel.cd("/path_directory")

ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
channel.connect();
channel.cd("/path_directory");

Upvotes: 0

Iv&#225;n Travecedo
Iv&#225;n Travecedo

Reputation: 75

I had a similar problem and it was due an non existent folder. Did you check if the folder exists? Is it in the correct path?

Upvotes: 0

Related Questions