Hi Antoine,
Hmmm, I never got that error before.
What version of the SSH server are you running on B and C?
Regards,
Andre
Antoine B wrote:
> Thanks for your help Andre!
>
> Here is my code :
>
> JSch jsch = new JSch();
> Session session = jsch.getSession("mylogin","B",22);
> UserInfo ui = new MyUserInfo();
> session.setUserInfo(ui);
> session.connect();
>
> // Setup port forwarding
> int assinged_port = session.setPortForwardingL(0,"C",22);
>
> // Connecting to remote system through port forwarding...
> Session session2 = jsch.getSession("mylogin","127.0.0.1
> ",assinged_port);
> session2.setUserInfo(ui);
> session2.connect();
>
> // We are now connected to system C (through B).
> // Lets run a command on system C
> Channel channel = session2.openChannel("exec");
> ((ChannelExec) channel).setCommand("ls -l");
> channel.connect();
>
> channel.setInputStream(System.in);
> channel.setOutputStream(System.out);
>
> and here is the error raised on session2.connect() :
>
> com.jcraft.jsch.JSchException: invalid server's version
> stringcom.jcraft.jsch.JSchException: invalid server's version string
>
> at com.jcraft.jsch.Session.connect(Session.java:256)
> at com.jcraft.jsch.Session.connect(Session.java:149)
> at UserAuthKI.main(UserAuthKI.java:30)
>
> Perhaps it's because C is only reachable through B?
>
>
> 2008/4/14, Andre Charbonneau <[EMAIL PROTECTED]>:
>> Hello,
>> Supposing we have 3 systems, A, B and C, here is how I do it in my
>> application:
>>
>> JSch jsch = new JSch();
>> session = jsch.getSession(
>> "<username on system B>",
>> "<hostname of system B>",
>> "<ssh port on system B>");
>> UserInfo ui = MyUserInfo();
>> session.setUserInfo(ui);
>> session.connect();
>>
>> // Setup port forwarding
>> int assinged_port = session.setPortForwardingL(
>> 0,
>> <hostname of system C>,
>> <ssh port on system C>);
>>
>> // Connecting to remote system through port forwarding...
>> Session session2 = jsch.getSession(
>> <username on system C>,
>> "127.0.0.1",
>> assinged_port);
>> session2.setUserInfo(ui);
>> session2.connect();
>>
>> // We are now connected to system C (through B).
>> // Lets run a command on system C
>> Channel channel = session2.openChannel("exec");
>> ((ChannelExec) channel).setCommand(<command to run on C>);
>> channel.connect();
>>
>>
>>
>> Hope this helps,
>>
>> Andre
>>
>>
>> Antoine B wrote:
>>
>>> Hello,
>>> What I want to do is simple :
>>> I want to connect on a server 'serv1', then with that connection opened
>>> I
>>> want to connect on a server 'serv2'. After that, I want to execute a
>>> script
>>> located on serv2.
>>> I want to do it automatically, without user's interaction (the users
>>> don't
>>> need to write in a shell for example).
>>> 'serv2' is only accessible from 'serv1' (no direct connnection is
>>> allowed).
>>> Is it possible with jsch?
>>> For the moment, I can open a connection on serv1, but the user had to
>>> type
>>> "ssh serv2" on the opened shell.
>>> Thanks and sorry for my english.
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>>
>>> -------------------------------------------------------------------------
>>> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't
>>> miss this year's exciting event. There's still time to save $100. Use
>>> priority code J8TL2D2.
>>> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> JSch-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/jsch-users
>>>
>>
>> --
>> Andre Charbonneau
>> Research Computing Support, IMSB
>> National Research Council Canada
>> 100 Sussex Drive, Rm 2025
>> Ottawa, ON, Canada K1A 0R6
>> 613 993-3129
>>
>
--
Andre Charbonneau
Research Computing Support, IMSB
National Research Council Canada
100 Sussex Drive, Rm 2025
Ottawa, ON, Canada K1A 0R6
613 993-3129
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users