In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Linux how to use scp to achieve automatic remote backup, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
1. Set up a password-free ssh login as follows:
Suppose you have two SUSE LINUX servers, and now you need to log in to 252 with root, and you don't need to enter a password, then we can follow these steps:
1) generate a key pair on the 250 machine and execute the following command:
# ssh-keygen-t rsa
Generating public/private rsa keypair.
Enter filein which to save the key (/ root/.ssh/id_rsa): enter directly (you can also set your own path)
Enter passphrase (empty for no passphrase): enter directly
Enter same passphrase again: enter directly
Your identification has been saved in / root/.ssh/id_rsa.
Your public keyhas been saved in / root/.ssh/id_rsa.pub.
The key fingerprint is:
F6:61:a8:27:35:cf:4c:6d:13:22:70:cf:4c:c8:a0:23 root@linux-250
In this way, id_rsa and id_rsa.pub are generated under the / root/.ssh/ path, where id_rsa is the key and id_rsa.pub is the public key.
2) copy the id_rsa.pub generated on the 252 machine to the 252 machine, assuming that it is copied to the temporary directory of the 252 machine, for example:
# scp / root/.ssh/id_rsa.pub root@192.168.1.250:/tmp
3) use the root account to log in to the 252 computer, enter its home directory, create an authorized_keys file, and set permissions.
# cd root/.ssh
# cat / tmp/id_rsa.pub > > authorized_keys (you can also cp / tmp/id_rsa.pub authorized_keys)
# chmod 400authorized_keys (Note: if not successful, this sentence chmod 700 / root/.ssh is required)
# rm-f / tmp/id_rsa.pub
Log in to the 252 machine (ssh 192.168.1.252) and find that you can enter directly without a password.
Note:
The permissions of the authorized_keys file are very important. If you set it to 777, you still need to provide a password when you log in. Encryption authentication does not support insecure settings with high permissions.
The mutual trust access between the two servers can be realized by the same setting on the 252 machine.
Or you can add RSA and DSA authentication at the same time.
1. Host 250:
Ssh-keygen-t rsa
Ssh-keygen-t dsa
Cat id_rsa.pub > > authorized_keys
Cat id_dsa.pub > > authorized_keys
Scp / root/.ssh/authorized_keys > > Host 252:/root/.ssh/
two。 Host 252:
Ssh-keygen-t rsa
Ssh-keygen-t dsa
Cat id_rsa.pub > > authorized_keys
Cat id_dsa.pub > > authorized_keys
Scp / root/.ssh/authorized_keys > > Host 250:/root/.ssh/
Note: if mutual trust access is established between the three hosts, you can first establish mutual trust access between two of them, then copy the authorized_keys of either of the two to the third, generate id_rsa.pub and id_dsa.pub in the third and add them to authorized_keys, and copy this file back to those two to overwrite the original authorized_keys.
two。 Edit the crontab file
# vi / etc/crontab
For example, set to automatically copy files in a specified directory on 252 at 12:50 every day:
50 12 * root scp 192.168.1.252:/root/sysstat*.rpm / home
As shown in the figure:
Make the same settings on another station as above:
# vi / etc/crontab
For example, set to automatically copy files in a specified directory at 13:05 every day:
05 13 * root scp 192.168.1.250:/root/sysstat*.rpm / home
As shown in the figure:
3. So far, the mutual preparation of two computers has been realized.
Note: # scp-p 7455-r / home/lnmp0.4/ 192.168.1.252:/opt/tom/
The-p parameter indicates the port number to be connected (default port 22, add p parameter after changing the port)
The-r parameter indicates recursive replication (that is, copying files and directories under that directory)
After reading the above, have you mastered how to use scp to achieve automatic remote backup in linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.