Posted by: xask | May 14, 2010

Ant SCP task through http_proxy

I was trying to remote copy a war file for deployment to a server,
which can be done using
1.  <scp verbose=”true” file=”remote_deployment/file.war” todir=”user:pass@~/jetty/webapps”/>
2.  We just need to add a jar to the ANT classpath for this to work  available here

the problem I faced was that I was behind a proxy, and there is currently no way of specifiying a proxy for Jsch from a build file. (here is <setproxy /> task but it does not work with Jsch.
The solution : JSch library is a implementation of SSH in pure java, so we modify it to do that
I patched the src/com/jcraft/jsch/ file to get the environment variable (http_proxy) and use it for initiating a connection through the proxy to the host.
Here is the patched jar file
download it from here
Another point : on most systems http_proxy won’t be available on non login shells.
hence we need to set the environment variable in eclipse,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: