Create the config file under your .ssh folder.
So instead of
Reference: Matt Ryall – Configuring your favourite hosts in SSH
After we have used Puppet to update a service config file, we would like to restart the service so as to apply the new changes to the service.
Say for example, we want to keep the SSH service alive and whenever the /etc/ssh/sshd_config is synchronized from the Puppet server, restart the SSH service. This can be done as follow.
Continue reading Puppet – Restart a service after a file has changed →
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.
<sshexec command="/bin/bash -l -c '[your commmand]'" .../>
Reference: StackOverflow – sshexec ant task: environment variables
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.
Continue reading PowerShell – Add private key for Key Authentication SSH →
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.
rsync --bwlimit=100 -v -e ssh /home/ykyuen/* ykyuen@remote-server:/home/ykyuen/
The bandwidth is limited to 100kb/s.
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…
Just like what we have discussed in Apache Ant – Using scp and sshexec tasks in build.xml, you need to define the <sshexec> or <scp> tasks in the Ant script. Try to configure your pom.xml as follow.
<!-- Deployment using Ant -->
<!-- Include Ant-Contrib tasks -->
<!-- Include sshexec task -->
<!-- Add the sshexec and scp task -->
<!-- Rest of the Ant script -->
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.
There are 2 ways to enable the <scp> and <sshexec> tasks in the Ant build.xml.
Continue reading Apache Ant – Using scp and sshexec tasks in build.xml →
I try to checkout a project on Subversion through the SVN+SSH protocol in Jenkins. It prompts for the credentials as follow.
Continue reading Jenkins – NullPointerException when setting up the SVN+SSH Authentication →
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.
1. Add your private key in pageant.exe.
Continue reading TortoiseSVN – SVN+SSH protocol with SSL key authentication →
My server was hacked. ToT
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 →