title: Permission denied using JSch
body: <p>I'm trying to retrieve some files from sftp server using JSch but I'm getting the following error.</p>
  
  <pre><code>3: Permission denied
  at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2846)
  at com.jcraft.jsch.ChannelSftp._realpath(ChannelSftp.java:2340)
  at com.jcraft.jsch.ChannelSftp.cd(ChannelSftp.java:342)
  at com.company.common.sftp.impl.managedFile.moveFiles(managedFile.java:712)
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>private List&lt;String&gt; moveFiles(String prefixFileName, String path) {
      Session session = getSession();
      Channel channel = connect(session);
      ChannelSftp channelSftp = null;
      try {
          channelSftp = (ChannelSftp)channel;
          channelSftp.cd(_workingDir);
      ...
      }
      ...
      finally {
          channel.disconnect();
          session.disconnect();
      }
  }
  
  public Session getSession() {              
      Session session = null;
      JSch jsch = new JSch();
      session = jsch.getSession(_user,_server,_port);
      session.setPassword(_password);
      java.util.Properties config = new java.util.Properties();
      config.put("StrictHostKeyChecking", _strictHostKeyChecking);
      session.setConfig(config);
      session.connect();
      return session;
   }
  
  public static Channel connect(Session session) {
    Channel channel = null;
    channel = session.openChannel("sftp");
    channel.connect();
    return channel;
  }
  </code></pre>
  
  <p><code>_workingDir</code> is a property with the following value: <code>/user_files</code>.
  Both folders (source and destination) are on a Windows server and all the privileges was granted to any user. But for some reason it doesn't let me change the current directory in the source (remote) server.</p>
  
  <p>Any idea?</p>
  
  <p><strong>UPDATE:</strong> The Sftp server is freeFTPd and using a sftp client (like Filezilla) I can move files without problems</p>