08-24-2020, 10:43 AM
#! /bin/bash
Remote host : 192.168.7.1
Directory : /MyTask #which i want to copy on remote host and keep synchronization
############################### For Sync between two folder ################################
#First Copy the directory to the remote host (192.168.7.1) using the command SCP:
scp -r /MyTask/ [email protected]:/
#Then create a keygen using SSH for Auto Login
ssh-keygen
#ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh-copy-id [email protected]
rsync -avz /MyTask/ [email protected]:/a/
################################ For Automate ###############################################
# Create a shell script for automatic Synchronization
vim /autosync.sh
#and paste the code
while true; do
rsync -avz /MyTask/ [email protected]:/a/
done
# Then give the Execution permission to the file
chmod +x /autosync.sh
#Do entry in crontab
crontab -e
#*/1 * * * * /autosync.sh
################################# For use a different Port ##################################
#/etc/ssh/sshd_config.
#Port 22
#Port 1234
#/etc/init.d/sshd restart
#semanage port -l | grep ssh
#semanage port -a -t ssh_port_t -p tcp 1234
#scp -p 80 [email protected]:/root/file.txt
#ssh -p 12345 [email protected]
Remote host : 192.168.7.1
Directory : /MyTask #which i want to copy on remote host and keep synchronization
############################### For Sync between two folder ################################
#First Copy the directory to the remote host (192.168.7.1) using the command SCP:
scp -r /MyTask/ [email protected]:/
#Then create a keygen using SSH for Auto Login
ssh-keygen
#ssh-keygen -t rsa -b 4096 -C "[email protected]"
ssh-copy-id [email protected]
rsync -avz /MyTask/ [email protected]:/a/
################################ For Automate ###############################################
# Create a shell script for automatic Synchronization
vim /autosync.sh
#and paste the code
while true; do
rsync -avz /MyTask/ [email protected]:/a/
done
# Then give the Execution permission to the file
chmod +x /autosync.sh
#Do entry in crontab
crontab -e
#*/1 * * * * /autosync.sh
################################# For use a different Port ##################################
#/etc/ssh/sshd_config.
#Port 22
#Port 1234
#/etc/init.d/sshd restart
#semanage port -l | grep ssh
#semanage port -a -t ssh_port_t -p tcp 1234
#scp -p 80 [email protected]:/root/file.txt
#ssh -p 12345 [email protected]