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

服务器root用户

[root@localhost ~]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.146.128  netmask 255.255.255.0  broadcast 192.168.146.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.146.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.146.1
[root@localhost ~]# 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我和程序有一个能跑就行

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值