已有desktop和server兩臺虛擬機,配置如下:
1)打包desktop主機上的/home目錄,格式爲YYYY_MM_DD_home.tar.gz並保存在/mnt目錄;
tar zcf /mnt/`date +%F`.tar.gz /home
2)無密碼傳輸該打包文件到server主機的/home/student/目錄下;
ssh-keygen
ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]
scp /mnt/2017-01-10.tar.gz [email protected]:/home/student/
3)desktop主機通過命令將server主機的壓縮包解壓到/home/student/Downloads目錄下;
tar xf /home/student/2017-01-10.tar.gz -C /home/student/Downloads
4)不允許以密碼認證方式遠程連接server主機。
vim /etc/ssh/sshd_config
78行改爲 PasswordAuthentication no
5)只允許student用戶通過祕鑰方式遠程登錄
vim /etc/ssh/sshd_config
Allowusers student
6)爲保證系統安全不允許以root用戶身份連接server主機
vim /etc/ssh/sshd_config
48行改爲 PermitRootLogin no