Sunday, July 5, 2009

Ant, SCP and EC2

I've have had to deal with a strange set of circumstances

1. No ant-jsh.jar in my deployment

I got the error


Deploy.ant.xml:57: Problem: failed to create task or type scp

Cause: the class was not found.

This looks like one of Ant's optional components.

Action: Check that the appropriate optional JAR exists in



-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

Turns out that the default deployment of Ant (1.7) did not contain this jar on Mac OS-x 10.5. So I had to do two things

  1. Download the binary distribution of Ant 1.7, unpack the jar and copy ant-jsch.jar to /usr/share/ant/lib
  2. Download the implementation of the SSH java code from JCraft and copy it to /usr/share/ant/lib

2. I still can't SCP to EC2

So I know I can scp -i to this EC2 host, but the following Ant task fails

<scp localfile="dba.war"





/Volumes/Develop/Develop/Projects/HarpoonDeployMK9a/Deploy.ant.xml:57: neither password nor passphrase for user root has been given. Can't authenticate.

Turns out that you need the following in the SCP task for it to work with EC2



The passphrase that worked happened to be my password for my AWS account...


trk9 said...


man thank you! i was pulling my hair out over this too. very irritating that mac osx ships without ant-jsch.jar. i grabbed it from the binary as you did and my scp instantly worked (after placing jsch.jar in ANT_HOME/lib of course).

post much appreciated!


chubbard said...

Adding passphrase="" to your scp task works as well so you don't have to hard code your account password in there. Probably should fix that in ant scp. :-)