rsync over ssh with password

Subject:

CentOS

How I created backups through SSH with password

  • This is a security risk as people will see the password in the file

sshpass works however wasn't installed

  • yum install sshpass

then create bash script file

ex:sshpass -p "password" rsync -avz --log-file=/var/scripts/transaction-backup.log root@192.168.2.22:/var/www/html/business/app/tmp/tests/ /mnt/upload/backups/business/transaction/

then in crontab execute it

SHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=rootHOME=/

# For details see man 4 crontabs

# Example of job definition:# .---------------- minute (0 - 59)# |  .------------- hour (0 - 23)# |  |  .---------- day of month (1 - 31)# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# |  |  |  |  |  *  10 *  *  *  root /var/scripts/course_backup.sh  *  5  *  *  * root /var/scripts/transaction_backup.sh#30 18  *  *  * root    php -f /var/www/html/cron/opentickets.php

2015-01-25 08:24:00gstlouis