gokulvsmail | 2 Sep 14:47 2013
Picon

Exceptio while calling method Session.connect()

hi,

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 
com.sun.crypto.provider.DHKeyPairGenerator.initialize(DashoA13*..)
16:05:55,792 ERROR [STDERR]     at 
java.security.KeyPairGenerator$Delegate.initialize(KeyPairGenerator.java:627)
16:05:55,792 ERROR [STDERR]     at 
java.security.KeyPairGenerator.initialize(KeyPairGenerator.java:369)
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 
com.jcraft.jsch.Session.receive_kexinit(Session.java:577)
16:05:55,793 ERROR [STDERR]     at 
com.jcraft.jsch.Session.connect(Session.java:299)
16:05:55,793 ERROR [STDERR]     at 
com.jcraft.jsch.Session.connect(Session.java:162)

(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)

Picon

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!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
JSch-users mailing list
JSch-users@...
https://lists.sourceforge.net/lists/listinfo/jsch-users
DUPETY, ANTOINE (ANTOINE | 17 Jul 17:21 2013

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

Hi,

 

I put the full stack trace under

https://gist.github.com/anonymous/e806e774f36d143138e0

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!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
JSch-users mailing list
JSch-users@...
https://lists.sourceforge.net/lists/listinfo/jsch-users
DUPETY, ANTOINE (ANTOINE | 21 Jun 18:13 2013

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

Hi,

 

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

http://www.mail-archive.com/jsch-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org/msg01729.html

 

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.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
JSch-users mailing list
JSch-users@...
https://lists.sourceforge.net/lists/listinfo/jsch-users
Vahe nr | 21 Jun 09:22 2013
Picon

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.

Regards.
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
JSch-users mailing list
JSch-users@...
https://lists.sourceforge.net/lists/listinfo/jsch-users
Deepak | 11 Jun 15:41 2013
Picon

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.

http://p.sf.net/sfu/windows-dev2dev
Eric Knauel | 7 Jun 16:28 2013

Still "verify: false" errors with Java 7?

Hi,

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.
http://stackoverflow.com/questions/12279836/ssh-using-jschexception-verify-false-sometimes-fails
https://issues.apache.org/jira/browse/IVY-1374

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,

Eric
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 {
                System.out.println(
                    format("testing {0} times", totalCount));

                int i = 0;
                while (count.get() < totalCount) {
                    int j = count.get();
                    float rate = (j - i) / (delay / 1000);
                    i = j;
                    System.out.println(
                        format("i={0}, ok={1}, fail={2}, current rate: {3} connects/sec",
                            count.get(), okCount.get(), failCount.get(), rate));
                    Thread.sleep(delay);
                }
            } 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++) {
                count.incrementAndGet();
                try {
                    Session session = jsch.getSession(USER, HOST, PORT);
                    session.setPassword("sftparc");
                    session.connect();

                    //System.out.println(session.getConfig("kex"));
                    session.disconnect();
                    okCount.incrementAndGet();
                } catch (JSchException ex) {
                    ex.printStackTrace();
                    failCount.incrementAndGet();
                }
            }
        }
    }

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

        int loopsPerThread = 50000;
        int numThreads = 20;

        count.set(0);
        failCount.set(0);
        okCount.set(0);

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

        Thread pt = new Thread(new ProgessThread(numThreads * loopsPerThread));
        threads.add(pt);
        pt.start();

        for (int i = 0; i < numThreads; i++) {
            Thread t = new Thread(new RunConnect(loopsPerThread));
            threads.add(t);
            t.start();
        }

        for (Thread t : threads) {
            t.join();
        }

        System.out.println(
            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
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
JSch-users mailing list
JSch-users@...
https://lists.sourceforge.net/lists/listinfo/jsch-users
Danisment Gazi Unal | 1 Jun 14:27 2013

"Failure" exception in ChannelSftp._realpath()


Hello,

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.throwStatusError(ChannelSftp.java:2629)
        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.remoteAbsolutePath(ChannelSftp.java:2700)

        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,
Exception{
    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;
    if(type==SSH_FXP_STATUS){
      i=buf.getInt();
      throwStatusError(buf, i); <--- THIS IS LINE 2160 FROM WHICH EXCEPTION
IS THROWN.
    }
    i=buf.getInt();   // count

    byte[] str=null;
    while(i-->0){
      str=buf.getString();  // absolute path;
      if(server_version<=3){
        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.
http://p.sf.net/sfu/appdyn_d2d_ap2
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");
    jschSession.setTimeout(60000);
    jschSession.setPassword("mypassword");
    jschSession.connect();

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.
http://p.sf.net/sfu/appdyn_d2d_ap1
Ravi Joshi | 19 May 13:42 2013
Picon

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();
        session.setUserInfo(ui);
        session.connect();

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

        channel.setInputStream(null);
        channel.setOutputStream(null);
        channel.connect();
        channel.disconnect();
        session.disconnect();


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.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
JSch-users mailing list
JSch-users@...
https://lists.sourceforge.net/lists/listinfo/jsch-users
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 :
"com.jcraft.jsch.ChannelSftp.cd"
 
 
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
 
 
Thanks.
Laurent.
 
 
 
------------------------------------------------------------------------------
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.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
JSch-users mailing list
JSch-users@...
https://lists.sourceforge.net/lists/listinfo/jsch-users

Gmane