歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> 教你使用scp在Linux主機之間進行定時備份

教你使用scp在Linux主機之間進行定時備份

日期:2017/3/3 16:11:25   编辑:關於Linux

在兩台Linux主機,而且都是ssh權限,那就建議使用scp命令備份了,這種備份速度快且是加密傳輸,安全性高。但是大數據的文件,不建議使用這中方法去備份!

好的,實驗很簡單:

1 ssh傳輸需要密鑰的 我們需要創造密鑰用來驗證!

ssh服務器端:

[root@text ~]# ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): enter鍵

Enter passphrase (empty for no passphrase): enter鍵

Enter same passphrase again: enter鍵

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx [email protected]

[root@text ~]# cd .ssh/

[root@text .ssh]# ls

id_rsa id_rsa.pub known_hosts

[root@text .ssh]# scp id_rsa.pub [email protected]:/root/.ssh/authorized_keys

輸入目標主機的密碼 密鑰傳輸過去了

那麼下次傳輸文件 就不會在需要提示輸入密碼的!

這就為了我們crontab的寫計劃任務備份做了好的開頭了

作者署名:51cto博客 幼兒園童鞋

 

Copyright © Linux教程網 All Rights Reserved