配置ssh免密登陆:客户端主机通过redhat用户基于秘钥验证方式进行远程连接服务器的root用户

文章描述了在RHCE(红帽认证工程师)的第二次作业中,如何进行服务器的网络配置,包括IPv4和IPv6地址。然后,创建并传输SSH密钥,以便无密码远程登录到root用户。最后,展示了成功远程连接后的系统信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

RHCE第二次作业

服务器root用户

[root@localhost ~]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.130.128  netmask 255.255.255.0  broadcast 192.168.130.255
        inet6 fe80::20c:29ff:fe2c:de8  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:2c:0d:e8  txqueuelen 1000  (Ethernet)
        RX packets 309  bytes 30419 (29.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 247  bytes 24604 (24.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 17  bytes 2039 (1.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 17  bytes 2039 (1.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

客户端

创密钥:

[redhat@localhost root]$ ssh-keygen

密钥:

[redhat@localhost root]$ ll /home/redhat/.ssh
总用量 8
-rw-------. 1 redhat redhat 2622  3月 14 20:55 id_rsa
-rw-r--r--. 1 redhat redhat  582  3月 14 20:55 id_rsa.pub

传密钥给服务器root用户:

[redhat@localhost root]$ ssh-copy-id root@192.168.130.128

远程连接服务器root用户:

[redhat@localhost root]$ ssh 'root@192.168.130.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 failed login: Tue Mar 14 20:59:14 CST 2023 from 192.168.130.129 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Tue Mar 14 20:51:16 2023 from 192.168.130.1
[root@localhost ~]# 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值