Linux

Enabling FTP Services

1- Linux is configured to run the Telnet and FTP server, but by default, these services are not enabled. To enable the telnet service, login to the server as the root user account and run the following commands:

[root@blade04 backups]# service xinetd reload

2- Starting with the Red Hat Enterprise Linux 3.0 release (and in CentOS Enterprise Linux), the FTP server (wu-ftpd) is no longer available with xinetd. It has been replaced with vsftp and can be started from /etc/init.d/vsftpd as in the following:

[root@blade04 backups]# /etc/init.d/vsftpd start

If you want the vsftpd service to start and stop when recycling (rebooting) the machine, you can create the following symbolic links:
# ln -s /etc/init.d/vsftpd /etc/rc3.d/S56vsftpd
# ln -s /etc/init.d/vsftpd /etc/rc4.d/S56vsftpd
# ln -s /etc/init.d/vsftpd /etc/rc5.d/S56vsftpd

3- Configure FTP for root logins

Edit the files /etc/vsftpd.ftpusers and /etc/vsftpd.user_list and remove the 'root' line from each file.

4-
[root@blade04 backups]# /etc/init.d/vsftpd start

5-
[root@blade04 ~]# chkconfig --level 0123456 vsftpd on

Script To Remove Files

First make the script (in our case it is del-backup-files.bash in /scripts directory)

1-
[root@blade04 backups]# nano /scripts/del-backup-files.bash

2-Enter the text in the body of script:

#!/bin/bash
find /var/backups -mtime +3 -exec rm {} \;

(by this command from local host directory /var/backups files older then three days would be deleted)

3- Save the file (CTRL+O) and exit (CTRL+X)

4- chmod a+x /scripts/del-backup-files.bash (make the file executeable)

Now edit the crontab to run a script

5-

[root@blade05 ~]# crontab -e

6- Enter the detail of the script and when it would run ( in our case it would run the mentioned script at 14 (2pm) everyday.

00 16 * * * /scripts/del-backup-files.bash > /dev/null 2>&1

Cronjob To Remove Files

First make the script (in our case it is del-backup-files.bash in /scripts directory)

1-

[root@blade05 ~]# nano /scripts/del-backup-files.bash

2- Use this command to delete file older then three days from the directory /var/backups

[root@blade05 ~]# find /var/backups -mtime +3 -exec rm {} \;

3- Now edit the crontab to run a script

[root@blade05 ~]# crontab -e

and add

00 16 * * * /scripts/del-backup-files.bash > /dev/null 2>&1

Connect A Remote Machine Without Having To Enter Any Password

1-First we need to create a key pair on the source machine
[root@blade05 ~]# ssh-keygen -t rsa

2- Next we copy ~/.ssh/id_rsa.pub to destination machine and append to ~userid/.ssh/authorized_keys by doing
[root@blade05 ~]# cat id_rsa.pub >>~/.ssh/authorized_keys

3- Now set permissions of ~/.ssh/authorized_keys to 700 by doing this:
[root@blade05 ~]# chmod go-rwx,u+rwx ~/.ssh/authorized_keys

4- Run step no 2 & 3 on destination server.

5- Restart the sshd service on both host and destination:
[root@blade05 scripts]# service sshd restart

Now you can ssh, scp, rsync from host to destination without any password.

No comments:

Post a Comment