![]() There are many other commands which rsync provides. Lets copy it from server2 to current /tmp/ directory rsync -ztva :/home/downloads/home/scripts /tmp/ Lets say we want to copy the scripts directory which is under the same path but on server2. Similarly we can copy one remote server too, only difference is that for source and destination you need to follow the ssh syntax. Lets check our scripts directory now in /tmp/ pwd ls -lrt /tmp/scripts Now we see the scripts directory copied too, the difference is the trailing trash, If you dont specify the trailing slash, it copies the directory too. Sent 1, 076 bytes received 77 bytes 2, 306.00 bytes/sec Lets see if we can copy the whole directory now with files rsync -ztva /home/downloads/home/scripts. rwxr-xr-x 1 root root 47 [ 0m[ 01 32mget_free_memory.sh[0m ls -lrt get_free_memory.sh get_ipaddr.sh prepare.sh Seems like we didnt get the scripts directory, Lets see if we got the files. Ls: cannot access scripts: No such file or directory Seems like it has worked, let see if we got all the files and also the scripts directory pwd Sent 1, 059 bytes received 76 bytes 2, 270.00 bytes/sec We need to add the switch -a (archive) rsync -ztva /home/downloads/home/scripts/. Sent 16 bytes received 12 bytes 56.00 bytes/secĪs we see above the same didnt work. Lets try to copy the whole directory scripts with all the files in it rsync -ztv /home/downloads/home/scripts. Get_free_memory.sh get_ipaddr.sh prepare.sh Following scripts directory has few files in it. Sent 44 bytes received 12 bytes 112.00 bytes/sec You can also use verbose mode to print information rsync -ztv /home/downloads/SampleData.xlsx. If the file is too big, use the -z compress switch, Rsync will compress the files before transfer rsync -zt /home/downloads/SampleData.xlsx. Now we got the file and also preserved the timestamp rw-r-r- 1 root root 65801 SampleData.xlsx To keep the original timestamp rsync -t /home/downloads/SampleData.xlsx. Yes we got the file in the directory /tmp/ directory but the time stamp has changed. Lets copy the above file /home/downloads/SampleData.xlsx to our current directory /tmp rsync /home/downloads/SampleData.xlsx. rw-rw-r- 1 root root 65801 Oct 31 2018 /home/downloads/SampleData.xlsx Lets start with a simple case where we want to copy a single file from source to destination. #Grsync windows password PcThat's it, your local PC will now be able to authenticate with your remote server.How to use Rsync and Grsync to securely copy files In the second last command, replace the text between the quotation marks with that long public SSH key line. > $HOME/.ssh/authorized_keys chmod 0644 $HOME/.ssh/authorized_keys Copy it to your clipboard, and within your remote server run these commands: sudo su rsync mkdir -m 0700 $HOME/.ssh echo "ssh-rsa AAAAB. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDNhyYKsjcGGdXmzOM3742+c+TzMLFdZtrMPj1q6JWNWzgY/gTGVy1C72kw6BcTYSG8B8kLQlaBRl16m2Gm8Ra/U1wl0TYSufOnRKjGq2glnBPysWNzR6i9qd4h/byKa4ptNH/ieYkT+BnSJVo8fT0iboYwEaL9D0jPtYxFzZes2ctsGZ/zi78VlX9N224YBtoZcrxK6gzKtcIVrplsXt4MbMCPc0hfr9f2VMt0HignLphTDLQWKwF3sGi4OHDPzNTRkjyHazsIOFIKDLQgdsIJv7b2VMs028YDqPnXHZZl4Ix5vg8ssqE+s/J+rzS0B6gwj2b/f6vJMI9DmTk8SO5LKWtSl4lXjLpQ1eP+xjf3SeMFWWkk2tPpGBo6d+8VJT6htj9Ga927qx3bYJ3FDdqjoE/28yBzMsg3wKI8lobiQGIbF0B0jZmSeq42ds7dh76iU/LOraWJWJhKPIjCYHdaVqj5rgxSulUW6oqr/LOxMNwsj5NLpyKygr5/RVjCUpxQLw5G7AClmW5nOZDFUgtI1CAOzhG8oYQes7jE7ZbQKmMf9IGquNV1BCRGX2mbcYad77UE2IjzPqSG8pFGb7ekZA6ukUk61fqoheL4Zl2jmhhWoXQ09LZE9FNfr1UwIoZ+GwUcip8NPIZPSo+Z4yMB/5VNF7J0o76eTNwh0gZlEw= long line is the public SSH key. Open the /~.ssh/ file in a text editor and you will see one large line that looks something like. To allow your local PC to authenticate, the public SSH key that was generated in the previous section needs to be copied over to the remote server. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |