一、要求:
1. 配置两台主机
- 主机1.
主机名: server.example.com;
ip: 172.25.254.100;
建立用户timinglee,其密码为timinglee;
- 主机2
主机名:client.example.com;
ip: 172.25.254.200;
2. 按需求完成项目
- 172.25.254.200 在远程登录172.25.254.100的root用户时需要免密连接
- 并确保只有root用户和timinglee用户可以被登录。
二、配置实现文档
1. 配置主机1(服务器)
[root@sever100 ~]# hostnamectl hostname server.example.com
[root@server ~]# hostname
server.example.com
[root@server ~]# passwd timinglee
[root@server ~]# systemctl stop firewalld
[root@server ~]# systemctl status firewalld
2. 配置主机2(客户端)
[root@sever200 ~]# hostnamectl hostname client.example.com
[root@client ~]#systemctl stop firewalld
[root@client ~]# systemctl status firewalld
[root@client ~]# ssh-keygen -f /root/.ssh/id_rsa
[root@client ~]# cd /root/.ssh/
[root@client .ssh]# ls
id_rsa id_rsa.pub known_hosts known_hosts.old
[root@client ~]# ssh-copy-id root@192.168.198.128
[root@client ~]# ssh root@192.168.198.128
3. 配置服务器sshd白名单
[root@server home]# vim /etc/ssh/sshd_config #服务器上配置sshd服务白名单
[root@server home]# systemctl restart sshd.service #注意修改配置后必须重启服务
三、测试
[root@client .ssh]# ssh -l root 192.168.198.128
Activate the web console with: systemctl enable --now cockpit.socket
Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Sun Apr 21 22:19:42 2024