配置密钥对的双向配置

HOST1配置:

root下编辑/etc/ssh/sshd_config 

RSAAuthentication  yes                  //启用RSA算法

PubkeyAuthentication   yes        //启用秘钥对验证

[root@host1 ~]# useradd hadoop              //建立一个用户

[root@host1 ~]# passwd hadoop          //设置密码

更改用户 hadoop 的密码 。      

新的 密码:

无效的密码: 密码少于 8 个字符

重新输入新的 密码:

passwd:所有的身份验证令牌已经成功更新。

[root@host1 ~]# su - hadoop

上一次登录:五 8月 16 03:44:00 CST 2019pts/0 上

[hadoop@host1 ~]$ pwd

/home/hadoop

[hadoop@host1 ~]$ ssh-keygen -t rsa                  //生成密钥对,加密格式为rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):              //密钥路径

Created directory '/home/hadoop/.ssh'.

Enter passphrase (empty for no passphrase):                          //公钥密码,回车即设置空密码(回车)

Enter same passphrase again:                                               //二次输入公钥密码(回车)

Your identification has been saved in /home/hadoop/.ssh/id_rsa.

Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.

The key fingerprint is:

77:05:b5:65:b7:b6:81:79:79:6d:2d:13:e2:73:65:4e hadoop@host1

The key's randomart image is:

+--[ RSA 2048]----+

|            o.o E|

|           . ooX*|

|            oo***|

|             +o++|

|        S . .  . |

|         . .     |

|                 |

|                 |

|                 |

+-----------------+

[hadoop@host1 ~]$ ssh-copy-id -i .ssh/id_rsa.pub hadoop@192.168.50.112        //将公钥传给位于host2下的hatoop

/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

hadoop@192.168.50.112's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'hadoop@192.168.50.112'"

and check to make sure that only the key(s) you wanted were added.

[hadoop@host1 ~]$ ssh hadoop@192.168.50.112         //无需验证密码即可登录

Last login: Thu Aug 15 20:10:32 2019 from 192.168.50.111

[hadoop@host2 ~]$

HOST2配置:

root下编辑/etc/ssh/sshd_config 

RSAAuthentication  yes                  //启用RSA算法

PubkeyAuthentication   yes        //启用秘钥对验证

[hadoop@host2 ~]$ mkdir .ssh

[hadoop@host2 ~]$ chmod 700 .ssh/

[hadoop@host2 ~]$ ls -ld .ssh/

drwx------. 2 hadoop hadoop 6 8月  15 20:02 .ssh/

[hadoop@host2 ~]$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):      //密钥路径

Enter passphrase (empty for no passphrase):                                  //输入公钥密码,回车即空密码(回车)

Enter same passphrase again:                    //再次输入(回车)

Your identification has been saved in /home/hadoop/.ssh/id_rsa.

Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.

The key fingerprint is:

f3:37:cc:fa:98:d6:ed:79:db:b6:68:13:cf:21:5f:66 hadoop@host2

The key's randomart image is:

+--[ RSA 2048]----+

|                 |

|                 |

|                 |

|                 |

|        S        |

|         o o o .E|

|          ..=.*oo|

|          .=.+o=+|

|         .+.oo+=+|

+-----------------+

[hadoop@host2 ~]$ ssh-copy-id -i .ssh/id_rsa.pub hadoop@192.168.50.111    //将公钥文件传给HOST1

/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

hadoop@192.168.50.111's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'hadoop@192.168.50.111'"

and check to make sure that only the key(s) you wanted were added.

[hadoop@host2 ~]$ ssh hadoop@192.168.50.111                   //直接登录,无需验证密码

Last login: Fri Aug 16 04:12:03 2019 from 192.168.50.112

[hadoop@host1 ~]$

CenOS7秘钥双向验证的配置的更多相关文章

  1. 构建秘钥对验证的SSH体系

    构建秘钥对验证的SSH 体系 首先先要在ssh 客户端以root用户身份创建秘钥对 客户端将创建的公钥文件上传至ssh服务器 服务器将公钥信息导入用户root的公钥数据库文件 客户端以root用户身份 ...

  2. Git秘钥生成以及Gitlab配置

    安装Git:详见http://www.cnblogs.com/xiuxingzhe/p/9300905.html 开通gitlab(开通需要咨询所在公司的gitlab管理员)账号后,本地Git仓库和g ...

  3. Git秘钥生成以及Gitlab配置(附以下问题解决方法:Key is invalid Fingerprint cannot be generated)

    在进行Git密钥配置时,总是提示: “The form contains the following errors:Key is invalidFingerprint cannot be genera ...

  4. ssl/https双向验证的配置

    1.SSL认证 不需要特别配置,相关证书库生成看https认证中的相关部分 2.HTTPS认证 一.基本概念 1.单向认证,就是传输的数据加密过了,但是不会校验客户端的来源  2.双向认证,如果客户端 ...

  5. ssl https双向验证的配置与证书库的生成

    1.SSL认证 不须要特别配置,相关证书库生成看https认证中的相关部分 2.HTTPS认证 一.基本概念 1.单向认证,就是传输的数据加密过了,可是不会校验client的来源  2.双向认证,假设 ...

  6. nginx配置ssl双向验证 nginx https ssl证书配置

    1.安装nginx 参考<nginx安装>:http://www.ttlsa.com/nginx/nginx-install-on-linux/ 如果你想在单IP/服务器上配置多个http ...

  7. Android中保存静态秘钥实践(转)

    本文我们将讲解一个Android产品研发中可能会碰到的一个问题:如何在App中保存静态秘钥以及保证其安全性.许多的移动app需要在app端保存一些静态字符串常量,其可能是静态秘钥.第三方appId等. ...

  8. soapui测试https双向验证p12项目

    1.准备好p12 和jsk秘钥文件 2.配置soapui ssl 其中: 1:jks就是放在trustStore那里,密码填写为 106075 2:p12放到keystore,密码填写:180000 ...

  9. git生成SSH秘钥

    1.进入git bash , 输入 cd ~/.ssh/ ,没有的话,自己创建 mkdir ~/.ssh , 然后进入该文件夹完成生成秘钥步骤 2.配置全局的name和email,这里是的你githu ...

随机推荐

  1. MYSQL查询今天、昨天、7天前、30天、本月数据

    今天: SELECT * FROM 表名 WHERE TO_DAYS( 时间字段名) = TO_DAYS(NOW()); 昨天: SELECT * FROM 表名 WHERE TO_DAYS( NOW ...

  2. POJ 1182-食物链 [并查集] 《挑战程序设计竞赛》2.4

    Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并不知道它到 ...

  3. NLP之中文自然语言处理工具库:SnowNLP(情感分析/分词/自动摘要)

    一 安装与介绍 1.1 概述 SnowNLP是一个python写的类库,可以方便的处理中文文本内容,是受到了TextBlob的启发而写的,由于现在大部分的自然语言处理库基本都是针对英文的,于是写了一个 ...

  4. windows修复失效图标

    taskkill /im explorer.exe /fcd /d %userprofile%\appdata\localdel iconcache.db /astart explorer.exeex ...

  5. Mysql:常用操作(导入数据,用户授权,远程连接授权,设置通信缓冲区的最大长度)

    1.导入数据命令: mysql --host=localhost --port=3306 --user=root --password=hnsjt_lwsj@2018 szyszx_20180515- ...

  6. charles获取抓包数据

    charles获取抓包数据 第一步:确保手机和电脑处于同一个局域网之下 第二步:进入 charles 的代理设定选项(主导航栏Proxy-----Proxy Setting......)中,允许代理, ...

  7. Python程序猿面试杂谈

    不同的互联网公司面试环节不尽相同,总体而言,一般有技术面(1-3轮).leader面(组长/总监/CTO/CEO...).hr面,面试轮数视公司规模和公司实际具体情况而定.下文将就面试的不同环节阐述下 ...

  8. read: Connection reset by peer

    造成此种问题的原因有多种,目前列下我所遇到过的. 1, sshfs usrname@172.23.65.122:/home/usrname ./122 在ubunutu 里面使用 sshfs 命令 映 ...

  9. 状态压缩DP:蒙德里安的梦想

    代码 #include<bits/stdc++.h> using namespace std; int n,m; long long f[12][1<<11]; bool yy ...

  10. ASP.NET Session详解(转)

    ASP.NET Session详解 本文章来自:http://blog.163.com/adam601@126/blog/static/22506317200932824210996/ 当用户在 We ...