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/ root@192.168.7.1:/
#Then create a keygen using SSH for Auto Login
ssh-keygen
#ssh-keygen -t rsa -b 4096 -C "root@192.168.7.1"
ssh-copy-id root@192.168.7.1
rsync -avz /MyTask/ root@192.168.117.135:/a/
################################ For Automate ###############################################
# Create a shell script for automatic Synchronization
vim /autosync.sh
#and paste the code
while true; do
rsync -avz /MyTask/ root@192.168.7.1:/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 username@www.myserver.com:/root/file.txt
#ssh -p 12345 username@remotehost
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/ root@192.168.7.1:/
#Then create a keygen using SSH for Auto Login
ssh-keygen
#ssh-keygen -t rsa -b 4096 -C "root@192.168.7.1"
ssh-copy-id root@192.168.7.1
rsync -avz /MyTask/ root@192.168.117.135:/a/
################################ For Automate ###############################################
# Create a shell script for automatic Synchronization
vim /autosync.sh
#and paste the code
while true; do
rsync -avz /MyTask/ root@192.168.7.1:/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 username@www.myserver.com:/root/file.txt
#ssh -p 12345 username@remotehost