1.Put to remote host password :-
# echo "echo redhat" > /root/shashi/passwd
2.Create a data copy script :-
#!/bin/bash
export SSH_ASKPASS="/root/shashi/passwd"
setsid ssh -o StrictHostKeyChecking=no "root"@"192.168.10"
exit 1
OR
setsid scp -r "/root/shashi/*" "root"@"192.168.0.10:/root/shashi/data"
==========================
# chmod +x passwd
#chmod +x script.sh
#./script.sh
==========================================================
===========================================================
#!/bin/bash
Path=/tmp
d=$(date +%d --date="1 days ago")
file=$(ls -lh $Path | awk '{print $6 " " $7 " " $9}' | sed -n /$d/p)
count=`echo -n "$file" | wc -l`
if [ 0 == "$count" ];then
echo "date is not Match with file"
else
echo "date is Match with file"
fi
-=========================================================
How do I backup /var/www/html using rsync?
Run rsync over SSH using password authentication, passing the password on the command line:
$ rsync --rsh="sshpass -p myPassword ssh -l username" server.example.com:/var/www/html/ /backup/
======================================================================
export SSHPASS=password
sshpass -e ssh user@remotehost
No comments:
Post a Comment