#5 Session does not return

open
nobody
None
5
2004-10-13
2004-10-13
Anonymous
No

Hi

I'm trying to call a test.sh on host1 from host2 via
JSch, using the following code:

JSch jsch = new JSch();
jsch.addIdentity("/.ssh/id_dsa", "xx");

Session session = jsch.getSession(user, host1, port);

java.util.Properties config=new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);

MyUserInfo info = new MyUserInfo();
session.setUserInfo(info);

session.connect();

String command = "test.sh";

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

channel.connect();

channel.disconnect();
session.disconnect();

However the session never returns.
I have tried to use ssh directly and its works fine.
(ssh -p port -i .ssh/id_dsa -o "StrictHostKeyChecking
no" user@host1)

Any ideas whats wrong????

Discussion

  • Logged In: NO

    I'm having a similar problem. I'm using sshexec (Ant) and
    connetcting to a Windows box running SSH2 (ssh.com).

    At the termination of the sent command, the connection won't
    return. It's got to time out. :-b