Bug 26757 - sshexec hangs
sshexec hangs
Status: RESOLVED FIXED
Product: Ant
Classification: Unclassified
Component: Optional Tasks
1.6.0
Other Linux
: P3 normal with 3 votes (vote)
: 1.6.3
Assigned To: Ant Notifications List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2004-02-07 14:59 UTC by Eric Jain
Modified: 2005-03-14 01:03 UTC (History)
1 user (show)



Attachments
Patch to disconnect session explicitely when done (319 bytes, patch)
2004-06-11 16:46 UTC, Robert Anderson
Details | Diff
Patch to disconnect session explicitely when done (319 bytes, patch)
2004-06-11 16:47 UTC, Robert Anderson
Details | Diff
it's a fix to use for JSCH, not ANT!! (38.52 KB, patch)
2004-12-08 23:50 UTC, Greg Harris
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Jain 2004-02-07 14:59:59 UTC
Using the sshexec task in the following way causes the specified command to be 
executed, but after that the task hangs and never returns.

  <sshexec
    host="${host}"
    username="${user}"
    password="${pass}"
    trust="yes"
    command="ls"
  />

Tried both jsch 0.1.9 and the latest release, 0.1.13.

Running 'ssh user@host ls' from the command line works fine. 

Seems to have been observed by someone else as well: 
http://marc.theaimsgroup.com/?l=ant-user&m=106442868402154&w=2

scp, on the other hand, seems to be working fine.
Comment 1 glee 2004-03-18 08:25:56 UTC
I am also seeing this bug.  Using the following snippet...
	  <echo>Creating dir
${global.deploy.machinename}:${global.deploy.target.dir}</echo>
	  <sshexec host="${global.deploy.machinename}"
		  username="${global.deploy.remote.user}"
		  trust="true"
		  password="${global.deploy.remote.password}"
		  command="perl -ver"
		  timeout="60000" />
	  <echo>finished with perl</echo>

For us it seems to work against a sun solaris box but fails when trying to
connect to f-secure sshd service running on w2k.  Our client box is a w2k box
running ant 1.6.1

The behavior is that it returns output for the command, but hangs there until
the timeout is exceeded and then it fails.
Comment 2 Robert Anderson 2004-03-18 18:38:02 UTC
This is probably a bug in the jsch code, not the Ant task.
Comment 3 Jan Schroeder 2004-06-11 14:22:18 UTC
according to the developer of jsch this is not a jsch bug.
Here is his email:

Hi,

This is not a bug of jsch. That comes from the usage of jsch by Ant.
JSch allows you to run simultaneously multiple exec channels on
the single ssh session.  I guess that, in that problem, ssh session has 
been kept and sshexec task should explicitly disconnect that 
session at the end of exec operation.


Thanks,
--
ymnk
Comment 4 Robert Anderson 2004-06-11 16:46:53 UTC
Created attachment 11829 [details]
Patch to disconnect session explicitely when done
Comment 5 Robert Anderson 2004-06-11 16:47:10 UTC
Created attachment 11830 [details]
Patch to disconnect session explicitely when done
Comment 6 Robert Anderson 2004-06-11 16:51:01 UTC
Please test the attached patch. I just added after line 199...

session.disconnect();


Note: Both patches are the same. I accidentilly hit the refresh button in my 
browser after attaching the patch, so it uploaded it again.
Comment 7 Jan Schroeder 2004-06-11 19:25:03 UTC
this did not fix it. Task never reaches the disconnect() method.
I played some with jsch and believe it is indeed a jsch problem. Contacted jsch
maintainer with a fix.
Comment 8 Greg Harris 2004-12-08 23:50:33 UTC
Created attachment 13688 [details]
it's a fix to use for JSCH, not ANT!! 

I have fixed this myself using the source for JSCH.  However, I'm not
completely sure whether or not what I did is the absolute right way it should
behave, but I'm assuming it is.  The problem with SSHExec in ANT is that it is
waiting for Channel.isEOF(), but the channel never says it's done.  The Session
object has a case statement in the run() method for different SSH replies from
the server, in my case at least:

SSH_MSG_CHANNEL_CLOSE:
@ Line: 1043 says channel.disconnect() but this method never does anything
about making  eof=true; or Channel.eof(); (what ant is waiting for).

Also seems environmental, I do not have the problem on a Solaris Box using:

OpenSSH_3.7.1p1, SSH protocols 1.5/2.0, OpenSSL 0.9.7c 30 Sep 2003

but do have it using an otherwise identicle box using:

ssh: SSH Secure Shell 3.2.5 (non-commercial version) on sparc-sun-solaris2.8

We also don't have this problem on all our linux boxes, also using OpenSSH. 
Hope that's helpful to someone and I'll send this on to folks at JCraft to see
what they say.
Comment 9 Stefan Bodewig 2005-03-11 17:08:00 UTC
It probably doesn't hurt to disconnect in Ant anyway, even if it doesn't help
in this case.
Comment 10 Stefan Bodewig 2005-03-14 10:03:08 UTC
fixed as good as we can from within Ant.