A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 梦缠绕的时候 黑马粉丝团   /  2019-6-18 15:28  /  1185 人查看  /  2 人回复  /   1 人收藏 转载请遵从CC协议 禁止商业使用本文

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机器,不用输入密码,创建互信成功。

---------------------
原文:https://blog.csdn.net/sinat_34289015/article/details/91610358
有任何问题欢迎在评论区留言或者直接联系学姐哦~


2 个回复

倒序浏览
欢迎与学姐沟通DKA-2018
回复 使用道具 举报
感谢分享~~
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马