The <sshexec> task is a very handle tool for executing command on the server through SSH. But i find that the SSH session does not have the proper environmental variables. Here is a simple solution.
We can use PowerShell as a SSH client. If your SSH server requires key authentication, you can use the following command to add your private key before you could establish the SSH connection.
We can use the --bwlimit to limit the bandwidth being used by the rsync command. Here is an example which transfer the local files to a remote server using ssh+rysnc.
If you want to use the <sshexec> or <scp> tasks in the maven-antrun-plugin, you may find the following error.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (default-cli) on project fraudcheck: An Ant BuildException has occured…
Unlike the Ant Contrib library which could be included thru the <taskdef>, the <scp> and <sshexec> tasks could not be included in this way or it will throw the following errors.
A class needed by class org.apache.tools.ant.taskdefs.optional.ssh.Scp
cannot be found: com/jcraft/jsch/…
If you want to make use of the SCP protocol to do file transfer in Apache Ant, first, visit JCraft and download the jsch-0.1.50.jar.
In the past, i usually integrate SVN with Apache such that i could access the SVN repository through the HTTP protocol. Apache and SVN Integration
I could use TortoiseSVN to checkout the SVN repository with correct username and password. But sometimes, we need to use SVN+SSH to access the SVN repository. Here are the steps using SSH key authentication.
One day i found that i couldn’t login the server thru SSH and the CPU usage jumped to 100% for more than 12 hours. Finally i could login as root and found that a new user R00T was created and the SSH service was restarted with all settings in the sshd config file commented out. =.=
So from now on i will use Key Authentication instead of simple Password Authentication. Here is a very useful guide on Linode.com which shows you how to secure your server. Linode Library – Securing Your Server
In order to use the Key Authentication, you need to generate the private key and public key on your desktop/labtop computers. This is straight forward if you are a Mac or Linux user who could use the ssh-keygen command. But for Windows user, you have to use 3rd party program like PuTTYgen. I suggest using WinSCP + PuTTY. Continue reading Secure the SSH protocol by Key Authentication→