4

I am having issues with an SSHEXEC ant task.

I am trying to connect to a remote host and execute a command.

I am trying to use "keyfile" so I do not need to use user/pass and hitting an issue.

I can get it to connect, but getting prompted for:

[sshexec] Connecting to $HOST:22

[sshexec] Kerberos username [$Local_USER]:

[sshexec] Kerberos password for $Local_USER:

Now if I just hit return at each prompt, it proceeds and executes the command.

I am using this method for automation, so defeats the purpose if you need to interact.

Here is the ANT syntax:

<target name="explode" depends="deploy" description="Creating build on Deployment Server">
      <sshexec host="${host}"
             username="${user}"
             keyfile="c:\paul\testkey"
             trust="true"
             command="${bin}/createBuild.sh"/>
</target>

Ant version - 1.8.3 Jsch version - jsch-0.1.42 (also tried with jsch-0.1.29)

Can anyone help or advise if I am doing something wrong?

Thanks in advance.

Paul

Pulak Agrawal
  • 2,481
  • 4
  • 25
  • 49
Cambolie
  • 1,415
  • 2
  • 12
  • 14
  • Is it possible for you to use an older version of ANT ? – Pulak Agrawal Aug 03 '12 at 07:34
  • No reason why not, any particular version you would recommend? – Cambolie Aug 03 '12 at 08:24
  • well.. honestly a wild guess.. SSHEXEC task has been updated in ANT 1.8.3 to include new attributes. So just looking to eliminate/narrow down the error whether its with the network OR remote site (as Aaron suggested) OR with ANT/sshexec.. so any version prior to 1.8.2 should do – Pulak Agrawal Aug 03 '12 at 08:59
  • Tried with version 1.7.1 exactly the same issue :( – Cambolie Aug 03 '12 at 09:16
  • now that you have found the answer. please put that in an answer from and and accept so this solution becomes useful for others. – Pulak Agrawal Aug 13 '12 at 04:20

4 Answers4

2

The issue here lies within Java 7.

In JAVA 7 they have introduced Kerberos into the java.security and in such this has caused the issue to prompt for kerberos user / password before proceeding.

I have fixed this issue by downgrading to Java 1.6.

I am still researching the fix for the 1.7 version of Java - may require further configuration of the kerberos conf file for java.

Cambolie
  • 1,415
  • 2
  • 12
  • 14
2

You can downgrade to Java 1.6 as Cambolie suggested or you can just add -noinput to fix this problem.

For example:

ant -noinput [some_target]
Kai
  • 38,985
  • 14
  • 88
  • 103
2

This issue has now been addressed in the latest versions of Ant (1.9.1) and Jsch (0.1.50).

There was a bug report with Apache which shows it having been fixed as of Jan-2013.

amaidment
  • 6,942
  • 5
  • 52
  • 88
0

This is probably a misconfiguration on the remote side. It certainly shouldn't ask for the user name. Talk to your sysadmin about this. I'm also worried about Kerberos because that's completely unrelated to SSH.

Also make sure the public key is installed in the user's account.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • Thanks for the tips, I will speak to our unix admins, strange though as if I use standard SSH installed with openssh for windows, I do not get this issue it connects seemlessly without any prompting - this is why I am thinking it is a ANT issue? – Cambolie Aug 03 '12 at 09:03
  • Maybe but it's still triggered by something they put into the login shell scripts on the remote side. – Aaron Digulla Aug 03 '12 at 09:10
  • Hmmm the thing that puzzles me the most, is that if you just hit return at the prompts it continues with no issues... Confused. I have tried with several different versions of ANT and get the same issue. Unix admins tell me that there is nothing on the server configured that would require kerberos authentication. – Cambolie Aug 03 '12 at 09:30
  • Check what's in `createBuild.sh`. Run it with `command="bash -x ${bin}/createBuild.sh"` or whatever shell is configured in the first line of the script. – Aaron Digulla Aug 03 '12 at 09:39
  • 1
    Just found the issue - version of java! I was running 1.7 - just downgraded to 1.5 and not prompting for Kerberos anymore! Thanks for all the advice guys, much appreciated – Cambolie Aug 03 '12 at 09:42
  • Java surely isn't prompting you for the Kerberos login :-/ – Aaron Digulla Aug 03 '12 at 09:43
  • Strange but true - no longer getting prompted since I downgraded... There must be some changes in the way it handles security? – Cambolie Aug 03 '12 at 09:47
  • No. It's something else. Are you sure `java` is the executable provided by the runtime and not some wrapper script? – Aaron Digulla Aug 03 '12 at 09:48
  • 100%, The only change I have made is the java downgrade. I have tried using 1.7 and it prompts, I change my JAVA_HOME to point to 1.5 and now it works with no issues. – Cambolie Aug 03 '12 at 09:49
  • I can see at the start of my build, which version of java it is using. – Cambolie Aug 03 '12 at 09:50
  • Buildfile: C:\Documents and Settings\paul.campbell\My Documents\sandpit\PVCS Opt\rpwms-latest.xml Detected Java version: 1.5 in: C:\Program Files\Java\jre1.5.0_12 Detected OS: Windows XP – Cambolie Aug 03 '12 at 09:51
  • And for Java 7? But maybe it's a bug/feature in one of the JARs on the classpath on the remote side. – Aaron Digulla Aug 03 '12 at 09:54
  • Apache Ant(TM) version 1.8.3 compiled on February 26 2012 Buildfile: C:\Documents and Settings\paul.campbell\My Documents\sandpit\PVCS Opt\rpwms-latest.xml Detected Java version: 1.7 in: C:\Program Files\Java\jdk1.7.0_03\jre – Cambolie Aug 03 '12 at 09:56
  • In your previous post - maybe it's a bug/feature in one of the JARs on the classpath on the remote side. - Its just connecting and exploding a zip file on the server, so not interacting with any other java or ant on the other end, so would this still be the case? – Cambolie Aug 03 '12 at 10:00