SSH服务配置两台主机实现免密登陆(基于密钥验证)

1.分别安装SSH服务端和客户端

yum install openssh*  -y

2.创建密钥对

[root@A /]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? 

3.将公钥文件发送给对端

[root@A .ssh]# ssh-copy-id -i id_rsa.pub root@192.168.17.135
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "id_rsa.pub"
The authenticity of host '192.168.17.135 (192.168.17.135)' can't be established.
ECDSA key fingerprint is SHA256:Vx7YJMJHJvsQYQP9wqLRJkTumT5U6M2P7d06k4W/odU.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
		(if you think this is a mistake, you may want to use -f option)

验证结果

[root@A .ssh]# ssh root@192.168.17.135
Last login: Thu Nov  5 17:16:14 2020 from 192.168.17.1
[root@B ~]#     //成功由Assh到B

在B上重复A的操作最终实现免密登录效果

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值