Saturday, May 15, 2010

"rsync" configuration in Linux/Unix

What "rsync" can do ?

"rsync" can perform differential uploads and downloads (synchronization) of files across the network, transferring only data that has changed. The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection.

Hand's ON Practical :-

Recommended : Install "rsync" on both linux or unix machines. (only for redhat/fedora)
yum install rsync


Note: Always use rsync over ssh
Since rsync does not provide any security while transferring data it is recommended that you use rsync over ssh . This allows a secure remote connection. Now let us see some examples of rsync.
Task 1: Copy file from a local computer to a remote server. Copy file from "/data/office.tar.gz" to a remote server called "192.168.1.1"

$ rsync -v -e ssh
/data/office.tar.gz rohit@192.168.1.1:/home/nishith

Task 2: Copy file from a remote server to a local computer

Copy file "/home/nishith/data.txt" from a remote server "192.168.1.1" to a local computer "/tmp" directory:
$ rsync -v -e ssh nishith@192.168.1.1:/home/nishith/data.txt /tmp

Give Password:

Task: Synchronize a local directory with a remote directory

$ rsync -r -a -v -e "ssh -l nishith" --delete 192.168.1.1:/home/nishith/ /data

Task: Synchronize a remote directory with a local directory

$ rsync -r -a -v -e "ssh -l nishith" --delete /data 192.168.1.1:/home/nishith/

Task: Synchronize a local directory with a remote rsync server

$ rsync -r -a -v --delete rsync://192.168.1.1/data /home/nishith/

"rsync" command common options.

  • --delete : delete files that don't exist on sender (system)
  • -v : Verbose (try -vv for more detailed information)
  • -e "ssh options" : specify the ssh as remote shell
  • -a : archive mode
  • -r : recurse into directories
  • -z : compress file data



Use "Iptables" for ssh & http connections per IP Address.

Allow "3 ssh" connections per client host:
/sbin/iptables -A INPUT -p tcp --syn --dport 22 -m connlimit --connlimit-above 3 -j REJECT

Allow "20 http" connections per IP (MaxClients is set to 60 in httpd.conf)
/sbin/iptables -A INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 20 -j REJECT --reject-with tcp-reset




Mount a remote folder through SSH

Subject : Mount a remote folder through SSH Service.

Command is :
$ sshfs user@server:/path/to/folder /mount/point

Syntax :
$sshfs nishith@192.168.1.21:/home/nishith /data/

You can mount a remote directory locally via SSH! You'll first need to install below programs however:

  • FUSE that allows to implement filesystems in userspace programs. (yum install fuse)
  • sshfs client that uses FUSE
  • sftp (secure ftp - comes with OpenSSH, and is on your system already) to access the remote host.

And that's it, now you can use sshfs to mount remote directories via SSH.

To Unmount, use:

fusermount -u "mount point"


Regards,
Nishith Vyas

Monday, May 3, 2010

Login as a root from GUI RHEL6 BETA

WARNING :- Its not at all good to login as root from GUI. It’ DANGEROUS. BUT if some one wants to know that how to login as a root from GUI then follow the instructions.

In RHEL6 Beta You cannot login as a root from GUI. By Default, Only Normal users are allowed in GUI Mode.

Follow these steps and you will able to login as a root from GUI on RHEL6 Beta.

Main Configurable File is "/etc/pam.d/".

Have a look of below steps.

Open your Terminal from Applications -> System Tools -> Terminal

Now Login as a root from your terminal

Step 1 :- [user@localhost]$ su – root
Password:-

Step 2:- Now go to your /etc/pam.d/ directory.

[root@localhost]# cd /etc/pam.d/

Then first take a backup of gdm file

cp gdm gdm.bkp ( always take backup if anything goes wrong you can correct it by original file)

Step 3 :- Now Open gdm file in your favorite editor. I am using vi as my editor.

[root@localhost]# vi gdm

Find and Comment or remove this line into your gdm file
auth required pam_succeed_if.so user != root quiet

Step 4 :- Save & Exit From that File.

Step 5 :- Here is the additional file that you need to edit and that file name is gdm-password. Open "gdm-password" file in your favorite editor. I am using vi as my editor.

Then first take a backup of gdm-password file

cp gdm-password gdm-password.bkp ( always take backup if anything goes wrong you can correct it by original file)

[root@localhost]# vi gdm-password

Find and Comment or remove this line into your gdm file
auth required pam_succeed_if.so user != root quiet



Step 6 :- Save & Exit from File. Now Logout and Try to Login as a root user. Now you are able to Login as a root user from GUI in RHEL6 Beta.

Thanks,

RHEL6 Beta Edition.