LinuxA机器与B机器创建互信

1、首先在A机器上生成私钥

使用ssh-keygen命令,然后一直回车

[zch@localhost ~]$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/zch/.ssh/id_rsa): 
Created directory '/home/zch/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/zch/.ssh/id_rsa.
Your public key has been saved in /home/zch/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Zvk1MCj7I94fMaf/EknkdJHPC+XPt64Yk6Zy2ijKp48 zch@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|              .o |
|         .  o o. |
|      . . o+ .oo |
|       o . oo. .o|
|      . S o.+...o|
|       + . *+. .+|
|      . o += .  o|
|  . .+ +oooo=  . |
|   E=.oo=+...++. |
+----[SHA256]-----+

在/home/${user}/.ssh目录下生成id_rsa、id_rsa.pub文件,代表成功。

2、然后向B机器发送私钥

使用ssh-copy-id命令,然后按照提示输入yes,用户密码

[zch@localhost .ssh]$ ssh-copy-id zch@192.168.9.129
The authenticity of host '192.168.9.129 (192.168.9.129)' can't be established.
ECDSA key fingerprint is SHA256:nPIWsnSi7IfOHvCU38SW3Yq578WhyVdTUDC21BkcIm4.
ECDSA key fingerprint is MD5:29:25:23:1b:4c:63:9d:d7:dd:53:3b:ce:98:65:03:31.
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: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
zch@192.168.9.129's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'zch@192.168.9.129'"
and check to make sure that only the key(s) you wanted were added.

3、最后再从A机器ssh连接B机器,不用输入密码,创建互信成功。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值