Archive for » November, 2008 «

Thursday, November 20th, 2008 | Author: Angelo

Deleting directories and files starting with special characters on linux server. Suppose you find directories and files starting with special characters for example —- ##– ##### ## #-#- . Removing it using command rm -rf will give you following output.

[root@Linux ~]# rm -rf ----
rm: unrecognized option `----'
Try `rm ./----' to remove the file `----'.
Try `rm --help' for more information.

Or trying to remove directory with name #-#- will not produce any output (means it will not give any error) but also it will not get delete. ls -l will list directory #-#-

[root@Linux ~]# rm -rf #-#-

[root@Linux ~]# ls -l
total 8
drwxr-xr-x 2 root root 4096 Nov 20 18:25 #-#-

To remove all these directories or files starting special characters just add ./ before name.

[root@Linux ~]# rm -rf ./#-#-

[root@Linux ~]# rm -rf ./----

And you have deleted files & directories starting with special character.

Monday, November 10th, 2008 | Author: Angelo

SSH without authentication while opening multiple sessions.

While working on a remote server via SSH, we need to open multiple sessions for the same remote server. Suppose, you are logged into a server 10.10.10.1, and now you want to transfer a file to server X from your local machine. Then you will have to copy those files using scp, for which you need to enter password while establishing a fresh connection to server X. So, it takes some time as well as it is irritating to enter password again and again.

Here’s the remedy :

Open the file /etc/ssh/ssh_config on your local machine as root to edit. Or if you are not the root user, you can create a file ~/.ssh/config for user level SSH configurations.

Add the following lines at the end of the file you opened just now:

ControlMaster auto
ControlPath /tmp/ssh-%r@%h:%p

Save the file and you are done !!

Now check out (One can try it this way) - Open a terminal and connect to a server :

$ ssh root@10.10.10.1

The connection gets established after entering the proper password.

Then in another terminal try to copy a file from your local machine to the same server :

$ scp -r ~/pintos root@10.10.10.1

This time, you don’t need to wait for a fresh connection, neither you will have to enter the password again. File transfer starts instantaneously. SSH shared the already established connection. Similarly you can open another terminal without waiting and entering the password again.

Saturday, November 01st, 2008 | Author: Angelo

Installation of apache module mod_limitipconn on cPanel server (apache version 2.X)

mod_limitipconn is used for limiting number of connections from each ip to particular site by enabling it in virtualhost of particular site. Suppose site name is mysitename.com and it’s cPanel username mysite.

Installation :: installing module mod_limitipconn

Download mod_limitipconn & untar the file. After downloading compile mod_limitipconn with apache using following command.

/usr/local/apache/bin/apxs -cia mod_limitipconn.c

Once you finish with installation of module mod_limitipconn

Uncomment following line in virtual host of site mysitename.com in /etc/httpd/conf/httpd.conf

Include "/usr/local/apache/conf/userdata/std/1/mysite/mysitename.com/*.conf"

Now fire following command to create directory mysitename.com with it’s parent directory mysite.

mkdir -p /usr/local/apache/conf/userdata/std/1/mysite/mysite.com
cd /usr/local/apache/conf/userdata/std/1/mysite/mysite.com

Then, touch a file called ipconn.conf and in it add following line. So that site will have max 3 connections from each ip.

<Location />
MaxConnPerIP 3
# exempting images from the connection limit is often a good
# idea if your web page has lots of inline images, since these
# pages often generate a flurry of concurrent image requests
NoIPLimit image/*
</Location>

Now restart apache service.

We can directly add above lines in virtualhost of domain mysitenaem.com. But when easyapache will be done in the server, the above changes will be overwritten. To avoid this we recommend above this method.

Now run following cPanel script and restart apache service.
/scripts/ensure_vhost_includes –user=mysite