Linux 远程连接服务项目实战

一、要求:

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
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值