gokulvsmail | 2 Sep 14:47 2013

Exceptio while calling method Session.connect()


Am using jsch0.1.50

jvm :1.6 hotspot
os: Linux

Am using the jsch lib for my J2ee web application deployed in jboss 5 
GA.while calling the method session.connect() a getting the exception as.

java.security.InvalidAlgorithmParameterException: Inappropriate 
parameter type
16:05:55,792 ERROR [STDERR]     at 
16:05:55,792 ERROR [STDERR]     at 
16:05:55,792 ERROR [STDERR]     at 
16:05:55,793 ERROR [STDERR]     at com.jcraft.jsch.jce.DH.getE(DH.java:57)
16:05:55,793 ERROR [STDERR]     at com.jcraft.jsch.DHG1.init(DHG1.java:122)
16:05:55,793 ERROR [STDERR]     at 
16:05:55,793 ERROR [STDERR]     at 
16:05:55,793 ERROR [STDERR]     at 

(I have added a printStackTrace() method in the Session class file for 
getting this stackTrace,i hope i doesn't make any issues).
And when i tried with removing the jce.jar from the lib folder of my web 
(Continue reading)


Interactive command for exec channel problem

I open a connection to a server via exec channel but right after connect to the session, the prompt asks for credentials confirmation before execute the command I send. Is there a way to send the credentials before conenct to the channel?

Via Putty I have the following flow:

connect to ssh server IP => insert username => insert password => server prompts for credential confirmation: insert username => insert password =>run command

Can someone help me?

Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
JSch-users mailing list
DUPETY, ANTOINE (ANTOINE | 17 Jul 17:21 2013

Re: ls command block on com.jcraft.jsch.Channel$MyPipedInputStream



I put the full stack trace under


but the rest of the stack trace is mainly on our code


Thanks for your help

Antoine Dupety


See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
JSch-users mailing list
DUPETY, ANTOINE (ANTOINE | 21 Jun 18:13 2013

ls command block on com.jcraft.jsch.Channel$MyPipedInputStream



Until know we used jsch 1.41 we have some problem where stack go sometimes in BLOCKED mode over a cd command

See mail from Laurent Bartol



So we try to used the last version jsch 1.50 and we have now the following problem which never occurs before


During two days all working well and after some days the ‘ls’ command take more and more time (10 seconds, 30 seconds, 200 seconds, 400 seconds, 2000 seconds) then never give the hand back.

So at the end we are in the same situation where ls command is completely blocked


"Thread-503" prio=10 tid=0x00002aaad3cc5800 nid=0x4649 in Object.wait() [0x0000000074edb000]

   java.lang.Thread.State: TIMED_WAITING (on object monitor)

                at java.lang.Object.wait(Native Method)

                - waiting on <0x0000000648c96e80> (a com.jcraft.jsch.Channel$MyPipedInputStream)

                at java.io.PipedInputStream.read(PipedInputStream.java:327)

                - locked <0x0000000648c96e80> (a com.jcraft.jsch.Channel$MyPipedInputStream)

                at java.io.PipedInputStream.read(PipedInputStream.java:378)

                - locked <0x0000000648c96e80> (a com.jcraft.jsch.Channel$MyPipedInputStream)

                at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2869)

                at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2895)

                at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1617)

                at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1527)


Have you already observe such topics ?


This SF.net email is sponsored by Windows:

Build for Windows Store.

JSch-users mailing list
Vahe nr | 21 Jun 09:22 2013

Simple interactive shell script execution

Dear all,

I am trying JSCH for the first time, I have managed to execute a single Linux command over the net, but I didn't managed to perform this action:
Let suppose that I have this script:
echo "Enter your name: "
read name
echo $name

I want to execute this using JSCH how can I do that ?
Please if it is possible to send a little working code for that.

Thanks in advance for any help or suggestion.

This SF.net email is sponsored by Windows:

Build for Windows Store.

JSch-users mailing list
Deepak | 11 Jun 15:41 2013

Java jsch issue

I am trying use SCP to upload a file of size 2gb to a linux machine using JAVA 
Jsch api. After uploading few MB of data the process stops. Though it wont 
throw any exception it hangs where i write into outputstream in my code. 
Please suggest me the work around. 

This SF.net email is sponsored by Windows:

Build for Windows Store.

Eric Knauel | 7 Jun 16:28 2013

Still "verify: false" errors with Java 7?


I'm using JSch in a system that uses lots of connections to a SFTP 
server to transfer large amounts of data. This worked well with Java 6, 
but occasionally SSH connect fails with "verify: false" on Java 7.  The 
problem looks very much like the bug described in the release notes of 
version 0.1.50:

Changes since version 0.1.49:
- bugfix: "verify: false" error on Java7u6(and later).  FIXED.

Here's the stack trace I get:

com.jcraft.jsch.JSchException: verify: false
	at com.jcraft.jsch.Session.connect(Session.java:330)
	at com.jcraft.jsch.Session.connect(Session.java:183)

I still see this problem with Java 1.7.0u21 and JSch 0.1.50. The 
attached unit test connects to an OpenSSH server 1,000,000 times using 
20 threads. In 500,000 connects I see about two or three attempts that 
fail with the error described above.  I ran the test several times and 
the error usually first shows up after about 250,000 connections.

To find a work-around I changed some of the JSch configuration 
parameters that seem to be relevant for the key exchange --- without 
success. These configurations didn't work around the problem:

- turning compression off
- setting "kex" to "diffie-hellman-group-exchange-sha256"
- setting "kex" to "diffie-hellman-group-exchange-sha1"
- setting "kex" to "diffie-hellman-group1-sha1"

Is there something else I can try? Do you have any advice on debugging 
the problem?

Best regards,

import static java.text.MessageFormat.format;

import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import org.junit.Test;

public class JSchTest {

    private static final String USER = "sftparc";
    private static final String HOST = "localhost";
    private static final int PORT = 10022;

    private static final String HOST_KEY =
        "localhost ssh-rsa
AAAAB3NzaC1yc2EAAAABIwAAAQEAwpnB0iqtlvPcIJUh8EL+N7PJhn+il5Xe/PlbF6uPxu8dVRP3rQ/14M6NVGxm7IeEaCDofaqJkQsRHJkakDVhD1JJsqniykDBRCTUczcLLZ15z7CkIY/Dyt1WmfnFXh/gUcifShADYHukRucvy33gP2zMt8JYTGnWO3/i1dMwazEutbPygrdKi27yy67e50dfUlLy1Jfu+d8lCSf8fV+D3o8r9z89X7suP0481fMXjGSWZXeGohZ1WBxMK6dRFXqc0p/QQS9kHIz5Ted0Tu2dDLrs95Nv31XRmVKRnSBvJ2Ae7WCcr4cDzwSA6pQwQU1AWpQDC8J43o2SdalQak7zLQ==\n" +
        "[localhost]:10022 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwpnB0iqtlvPcIJUh8EL+N7PJhn+il5Xe/PlbF6uPxu8dVRP3rQ/14M6NVGxm7IeEaCDofaqJkQsRHJkakDVhD1JJsqniykDBRCTUczcLLZ15z7CkIY/Dyt1WmfnFXh/gUcifShADYHukRucvy33gP2zMt8JYTGnWO3/i1dMwazEutbPygrdKi27yy67e50dfUlLy1Jfu+d8lCSf8fV+D3o8r9z89X7suP0481fMXjGSWZXeGohZ1WBxMK6dRFXqc0p/QQS9kHIz5Ted0Tu2dDLrs95Nv31XRmVKRnSBvJ2Ae7WCcr4cDzwSA6pQwQU1AWpQDC8J43o2SdalQak7zLQ==\n";

    private static final AtomicInteger count = new AtomicInteger(0);
    private static final AtomicInteger failCount = new AtomicInteger(0);
    private static final AtomicInteger okCount = new AtomicInteger(0);

    private static class ProgessThread implements Runnable {

        private final int totalCount;
        private final int delay = 5000;

        private ProgessThread(int totalCount) {

            this.totalCount = totalCount;

         <at> Override
        public void run() {

            try {
                    format("testing {0} times", totalCount));

                int i = 0;
                while (count.get() < totalCount) {
                    int j = count.get();
                    float rate = (j - i) / (delay / 1000);
                    i = j;
                        format("i={0}, ok={1}, fail={2}, current rate: {3} connects/sec",
                            count.get(), okCount.get(), failCount.get(), rate));
            } catch (InterruptedException e) {
               // do nothing

    private static class RunConnect implements Runnable {

        private final int numLoops;

        private RunConnect(int numLoops) {
            this.numLoops = numLoops;

         <at> Override
        public void run() {

            JSch jsch = new JSch();
            try {
                jsch.setKnownHosts(new ByteArrayInputStream(HOST_KEY.getBytes()));
            } catch (JSchException e) {
                throw new IllegalStateException(e);

            for (int i = 0; i < numLoops; i++) {
                try {
                    Session session = jsch.getSession(USER, HOST, PORT);

                } catch (JSchException ex) {

     <at> Test
    public void testConnectParallel() throws Exception {

        int loopsPerThread = 50000;
        int numThreads = 20;


        List<Thread> threads = new ArrayList<Thread>();

        Thread pt = new Thread(new ProgessThread(numThreads * loopsPerThread));

        for (int i = 0; i < numThreads; i++) {
            Thread t = new Thread(new RunConnect(loopsPerThread));

        for (Thread t : threads) {

            format("finalResult: i={0}, ok={1}, fail={2}",
                count.get(), okCount.get(), failCount.get()));

How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
JSch-users mailing list
Danisment Gazi Unal | 1 Jun 14:27 2013

"Failure" exception in ChannelSftp._realpath()


JSch: 0.1.49/0.1.50
SSH Server: freeSSHd 1.2.4 on Windows

I got an exception with just "Failure" message. This is stack trace:

4: Failure
        at com.jcraft.jsch.ChannelSftp._realpath(ChannelSftp.java:2160)
        at com.jcraft.jsch.ChannelSftp.getHome(ChannelSftp.java:2230)
        at com.jcraft.jsch.ChannelSftp.getCwd(ChannelSftp.java:2245)

        at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:354)
        at com.jcraft.jsch.ChannelSftp.put(ChannelSftp.java:338)

This is the code of ChannelSftp._realpath:
  private byte[] _realpath(String path) throws SftpException, IOException,
    sendREALPATH(Util.str2byte(path, fEncoding));

    Header header=new Header();
    header=header(buf, header);
    int length=header.length;
    int type=header.type;

    fill(buf, length);

    if(type!=SSH_FXP_STATUS && type!=SSH_FXP_NAME){
      throw new SftpException(SSH_FX_FAILURE, "");
    int i;
      throwStatusError(buf, i); <--- THIS IS LINE 2160 FROM WHICH EXCEPTION
    i=buf.getInt();   // count

    byte[] str=null;
      str=buf.getString();  // absolute path;
        byte[] lname=buf.getString();  // long filename
      SftpATTRS attr=SftpATTRS.getATTR(buf);  // dummy attribute
    return str;

As I understand if type is SSH_FXP_STATUS, this problem occurs.

What does this probleam mean ? How can I solve it ?

thanks in advance.

Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
Justin Scott | 29 May 00:55 2013

Packet size exceeds maximum allowed

Good evening, I am attempting to write an automated process that will
connect JSch to a remote server and send a file.  Seems simple enough.
 Upon connection to a Serv-U SFTP server it is giving me the following
error on the Serv-U side:

    SSH Protocol Error: packet size exceeds maximum allowed.

Serv-U then closes the session, at which point JSch throws the exception:

    Session.connect: java.io.IOException: End of IO Stream Read

Here is the basic code in question:

    jsch = classLoader.create("com.jcraft.jsch.JSch").init(); //
ColdFusion-specific to load the jar
    jschSession = jsch.getSession("myusername", "ftp.example.com", 22);
    jschSession.setConfig("StrictHostKeyChecking", "no");

This is being loaded from within a ColdFusion application (which runs
on Java 7) using a Java class loader which is loading jsch-0.1.50.jar.

I am new to JSch, so if I'm missing something obvious please go easy
on me.  Any thoughts on what might be going awry?  Thanks in advance.

-Justin Scott

Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
Ravi Joshi | 19 May 13:42 2013

invoke shell script on remote Linux machine using JSch without waiting for the STDOUT/ERR from the shell

Hi all,

I want to invoke a shell script on remote Linux machine using JSch without waiting for the STDOUT/STDERR from the shell. I have modified the code available in JSch official website in the following manner-

        String command = "sh /opt/scripts/start.sh";
        JSch jsch = new JSch();
        Session session = jsch.getSession(user, host, 22);
        UserInfo ui = new MyUserInfo();

        Channel channel = session.openChannel("exec");
        ((ChannelExec) channel).setCommand(command);


The above code works perfectly. But can i get the status of invoke signal? I mean is there any way so that I can get that whether shell script is invoked successfully or not? Also I don't want to wait for its execution and STDOUT/STDERR.
-Ravi Joshi
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
JSch-users mailing list
BARTOL, LAURENT (LAURENT | 16 May 17:10 2013

com.jcraft.jsch.ChannelSftp.cd frozen

Hi everybody,
To sumary, we have a sFTP files collector
It has to collect files on different paths with a polling period
Thread 1 of collect
While (true)
        cd PathP
        get FileF
        sleep(X sec)
It has works several months and then I discovered that no more files were collected…
So we made several jstack and discovered the thread in charge of this job is frozen, since several days on command :
Thread 30610: (state = BLOCKED)
- java.lang.Object.wait(long) <at> bci=0 (Compiled frame; information may be imprecise)
- java.io.PipedInputStream.read() <at> bci=142, line=310 (Compiled frame)
- java.io.PipedInputStream.read(byte[], int, int) <at> bci=43, line=361 (Compiled frame)
- com.jcraft.jsch.ChannelSftp.fill(byte[], int, int) <at> bci=17, line=2325 (Compiled frame)
- com.jcraft.jsch.ChannelSftp.header(com.jcraft.jsch.Buffer, com.jcraft.jsch.ChannelSftp$Header) <at> bci=12, line=2351 (Compiled frame)
- com.jcraft.jsch.ChannelSftp._realpath(java.lang.String) <at> bci=27, line=1810 (Compiled frame)
- com.jcraft.jsch.ChannelSftp.cd(java.lang.String) <at> bci=14, line=268 (Interpreted frame)
- dpm.distributorFTP.SFTPClientWrapper.cd(java.lang.String) <at> bci=22, line=142 (Compiled frame)
- dpm.collectorFTP.CollectorFTPClient.scanServer() <at> bci=225, line=776 (Compiled frame)
- dpm.collectorFTP.CollectorFTPClient.collectorProcedure() <at> bci=144, line=612 (Interpreted frame)
- dpm.collectorFTP.CollectorFTPClient.access$1000(dpm.collectorFTP.CollectorFTPClient) <at> bci=1, line=90 (Compiled frame)
- dpm.collectorFTP.CollectorFTPClient$ThreadForScan.run() <at> bci=28, line=226 (Compiled frame)
- java.lang.Thread.run() <at> bci=11, line=619 (Interpreted frame)
To be able to continue the collecte,
We launched an other thread witch restart correcly the files collect
But the old thread is always frozen on jstack "com.jcraft.jsch.ChannelSftp.cd" !!!
I saw message about "ls" "frozen"
Does this problem on "cd" has been already met
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
JSch-users mailing list