Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9254067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:22:28+00:00 2026-06-18T11:22:28+00:00

I am trying to implement JSch to retrieve a file from remote windows sftp

  • 0

I am trying to implement JSch to retrieve a file from remote windows sftp server to Linux.

Session session = null;
    Channel channel = null;
    ChannelSftp channelSftp = null;
        try{
           JSch jsch = new JSch();
           session = jsch.getSession("userName","hostName",22);
           session.setPassword("password");
           java.util.Properties config = new java.util.Properties();
           config.put("StrictHostKeyChecking", "no");
          session.setConfig(config);
          session.connect();
          System.out.println(session.sendKeepAliveMsg());
          channel = session.openChannel("sftp");
          channel.connect();
         }catch(Exception e){
               e.printstacktrace();
         }

I am getting following exception while running this code.

com.jcraft.jsch.JSchException: java.io.IOException: inputstream is closed
    at com.jcraft.jsch.ChannelSftp.start(ChannelSftp.java:288)
    at com.jcraft.jsch.Channel.connect(Channel.java:152)

When I debug I found:

start();

method in Channel class is throwing the exception. Is there anyway I can prevent this? I don’t understand why the method is there without doing nothing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:22:29+00:00Added an answer on June 18, 2026 at 11:22 am

    Try to cast your channel into ChannelSft before the connect:

    Channel channel = session.openChannel("sftp");
    ChannelSftp channelSftp = (ChannelSftp) channel;
    channelSftp.connect();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying implement server code of Server-Sent Events in a generic way that any
I am trying implement Unblock me Puzzle. i want to change image position from
I'm trying implement Data Annotation to my Linq to SQL objects. The .dbml file
Trying to implement the following structure from c to use NSArray in objective-c: In
Trying to implement windows Progressbar showing progress of download in bytes with big numbers,
trying to implement a multiplayer. Using the sample from Game Center - Sending and
Trying to implement the example from here. Facebook Share passes along the URL of
Trying to implement following queries in NHibernate QueryOver. SQL SELECT SUM(GrossChargeAmount) FROM Charges INNER
I am trying implement drag and drop feature in RichTextBox (windows common control). It
Trying to implement, in Scala, the following Haskell function (from Learn You a Haskell...)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.