<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 28: Random error while trying to read directory</title><link>https://sourceforge.net/p/jsch/support-requests/28/</link><description>Recent changes to 28: Random error while trying to read directory</description><atom:link href="https://sourceforge.net/p/jsch/support-requests/28/feed.rss" rel="self"/><language>en</language><lastBuildDate>Tue, 30 Jan 2018 16:42:06 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/jsch/support-requests/28/feed.rss" rel="self" type="application/rss+xml"/><item><title>Random error while trying to read directory</title><link>https://sourceforge.net/p/jsch/support-requests/28/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Hello Dear support:&lt;/p&gt;
&lt;p&gt;I have a code that we use to access a server and read some files, but unfortunately  we are facing a random problem in this line: channel.lcd(localDir);  that occurs  very rarely.&lt;/p&gt;
&lt;p&gt;The code is below and the description of the error as well:&lt;/p&gt;
&lt;p&gt;Error&lt;/p&gt;
&lt;p&gt;2018-01-16 02:39:51,808 C &lt;span&gt;[TestScheduler_Worker-48]&lt;/span&gt; ERROR - Exception occurred:&lt;br/&gt;
3: Permission denied.&lt;/p&gt;
&lt;p&gt;Code&lt;br/&gt;
  Line: &lt;br/&gt;
          channel.lcd(localDir);&lt;br/&gt;
  Method:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;private ChannelSftp getSftpChannel() throws Exception {
    if (sftpSession == null) {
        JSch jsch = new JSch();
        sftpSession = jsch.getSession(user, host, port);
        java.util.Properties config = new java.util.Properties();
        config.put("StrictHostKeyChecking", "no");
        sftpSession.setTimeout(timeout);
        sftpSession.setConfig(config);

        // not ssl connection, will connect with username/password
        if (!ftpOverSSLFlag) {
            sftpSession.setConfig("PreferredAuthentications", "password,keyboard-interactive");
            sftpSession.setPassword(password);
        }else {
          // if private key will connect with key file
            jsch.addIdentity(privateKeyPath);
        }

        //Modify the way to connect to the sftp channel 
        if(noKeyboardInteractive){
          sftpSession.setConfig("PreferredAuthentications", "password");
    sftpSession.setPassword(password);
        }

        sftpSession.connect();
    }

    ChannelSftp channel = (ChannelSftp) sftpSession.openChannel("sftp");
    channel.connect();
    channel.cd(remoteDir);
    **channel.lcd(localDir);**
    return channel;
}
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Any help would be highly appreciated.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Daniel HG</dc:creator><pubDate>Tue, 30 Jan 2018 16:42:06 -0000</pubDate><guid>https://sourceforge.netdc2f52e09794690ffb7450658b76e949e13d4635</guid></item></channel></rss>