unit3.远程连接服务实战

文章详细描述了如何配置两台主机之间的SSH连接,包括设置主机名、IP,实现root用户和timinglee用户的免密登录,以及限制其他用户访问。还涉及了SSH配置文件的修改和使用SSH密钥对进行身份验证的过程。
摘要由CSDN通过智能技术生成

一.配置两台主机
主机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用户可以被登录

100机
[root@server 桌面]# vim /etc/ssh/sshd_config
     Port 2222
[root@server 桌面]# systemctl restart sshd
[root@server 桌面]# netstat  -antlupe  |  grep  sshd
tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      0          23872      9
[root@server 桌面]# vim /etc/ssh/sshd_config
PermitRootLogin yes
AllowUsers  timinglee root
PasswordAuthentication yes
[root@server 桌面]# systemctl restart sshd


200机
[root@client 桌面]# ssh-keygen -f /root/.ssh/id_rsa -P ""
[root@client .ssh]# ls
         id_rsa  id_rsa.pub  known_hosts  known_hosts.old
[root@client .ssh]# ssh-copy-id -i  id_rsa.pub root@172.25.254.100
[root@client .ssh]# ssh -l root 172.25.254.100  -p 2222
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: Sat Apr 20 22:33:06 2024 from 172.25.254.200
[root@server ~]# 
[root@client ~]# ssh -l timinglee 172.25.254.100  -p 2222
         timinglee@172.25.254.100's password: 
         Permission denied, please try again.
         timinglee@172.25.254.100's password: 
         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 failed login: Sat Apr 20 22:52:10 CST 2024 from 172.25.254.200 on ssh:notty
        There were 4 failed login attempts since the last successful login.
[timinglee@server ~]#

 

  • 28
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值