Tag Archives: SSH

SSH – Manage remote servers in SSH config

Create the config file under your .ssh folder.

Ex. /home/ykyuen/.ssh/config

Host remote1
HostName www.remote1.com
User ykyuen

Host remote2
HostName www.remote2.com
User kit


So instead of

ssh ykyuen@www.remote1.com


Just type

ssh remote1


Done =)

Reference: Matt Ryall – Configuring your favourite hosts in SSH


Puppet – Restart a service after a file has changed

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

Maven – Run sshexec and scp in maven-antrun-plugin

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 -->
      <taskdef name="sshexec"
        classpathref="maven.plugin.classpath" />
      <taskdef name="scp"
        classpathref="maven.plugin.classpath" />

      <!-- Rest of the Ant script -->


Done =)


Apache Ant – Using scp and sshexec tasks in build.xml

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

TortoiseSVN – SVN+SSH protocol with SSL key 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

Secure the SSH protocol by 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