已有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 root@172.25.254.173

scp /mnt/2017-01-10.tar.gz root@172.25.254.173:/home/student/

3)desktop主机通过命令将server主机的压缩包解压到/home/student/Downloads目录下;

ssh root@172.25.254.173

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