ssh from Ant

Filed under: Automation, — Tags: Ant, jsch, ssh, sshexec — Thomas Sundberg — 2012-01-16

You have to patch Ant in order to run ssh from it. It needs a ssh implementation that isn't bundled with the default distribution. If you just define a task like this:

<sshexec host="somehost"
    username="dude"
    password="yo"
    command="touch somefile"/>

Then you will get the error message below back.

BUILD FAILED
/Users/tsu/projects/linkon/fp/sabine/resources/deploy/build.xml:57: Problem: failed to create task or type sshexec
Cause: the class org.apache.tools.ant.taskdefs.optional.ssh.SSHExec was not found.
        This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
        -/usr/share/ant/lib
        -/Users/tsu/.ant/lib
        -a directory added on the command line with the -lib argument

Do not panic, this is a common problem.
The commonest cause is a missing JAR.

This is not a bug; it is a configuration problem

The solution is to download an ssh implementation and add it to your Ant installation. A valid implementation can be downloaded from JCraft. When you have downloaded and verified jsch-0.1.45.jar all you have to do is add it to your Ant installation. My installation was located at /usr/share/ant/ so I added it to /usr/share/ant/lib

I you are on a Mac, which I am, then this may not be sufficient. If you still get the error above, then take a look at a blog post I just wrote about ant being broken on Mac.

Resources



(less...)

Pages

About
Events
Why

Categories

Agile
Automation
BDD
Clean code
Continuous delivery
Continuous deployment
Continuous integration
Cucumber
Culture
Design
DevOps
Executable specification
Git
Gradle
Guice
J2EE
JUnit
Java
Javascript
Kubernetes
Linux
Load testing
Maven
Mockito
New developers
Pair programming
PicoContainer
Presentation
Programming
Public speaking
Quality
React
Recruiting
Requirements
Scala
Selenium
Software craftsmanship
Software development
Spring
TDD
Teaching
Technical debt
Test automation
Tools
Web
Windows
eXtreme Programming

Authors

Thomas Sundberg
Adrian Bolboaca

Archives

Meta

rss RSS