已有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目录下;
ssh [email protected]
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
时间: 2025-01-13 23:43:27