CenOS7秘钥双向验证的配置

配置密钥对的双向配置

HOST1配置:

root下编辑/etc/ssh/sshd_config

RSAAuthentication  yes                  //启用RSA算法

PubkeyAuthentication   yes        //启用秘钥对验证

[[email protected] ~]# useradd hadoop              //建立一个用户

[[email protected] ~]# passwd hadoop          //设置密码

更改用户 hadoop 的密码 。      

新的 密码:

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

重新输入新的 密码:

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

[[email protected] ~]# su - hadoop

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

[[email protected] ~]$ pwd

/home/hadoop

[[email protected] ~]$ 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 [email protected]

The key‘s randomart image is:

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

|            o.o E|

|           . ooX*|

|            oo***|

|             +o++|

|        S . .  . |

|         . .     |

|                 |

|                 |

|                 |

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

[[email protected] ~]$ ssh-copy-id -i .ssh/id_rsa.pub [email protected]        //将公钥传给位于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

[email protected]‘s password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh ‘[email protected]‘"

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

[[email protected] ~]$ ssh [email protected]         //无需验证密码即可登录

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

[[email protected] ~]$

HOST2配置:

root下编辑/etc/ssh/sshd_config

RSAAuthentication  yes                  //启用RSA算法

PubkeyAuthentication   yes        //启用秘钥对验证

[[email protected] ~]$ mkdir .ssh

[[email protected] ~]$ chmod 700 .ssh/

[[email protected] ~]$ ls -ld .ssh/

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

[[email protected] ~]$ 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 [email protected]

The key‘s randomart image is:

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

|                 |

|                 |

|                 |

|                 |

|        S        |

|         o o o .E|

|          ..=.*oo|

|          .=.+o=+|

|         .+.oo+=+|

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

[[email protected] ~]$ ssh-copy-id -i .ssh/id_rsa.pub [email protected]    //将公钥文件传给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

[email protected]‘s password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh ‘[email protected]‘"

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

[[email protected] ~]$ ssh [email protected]                   //直接登录,无需验证密码

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

[[email protected] ~]$

原文地址:https://www.cnblogs.com/yuan9910/p/11360408.html

时间: 2024-08-02 05:43:33

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

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

在进行Git密钥配置时,总是提示: “The form contains the following errors:Key is invalidFingerprint cannot be generated” 如下图: 查找了不少资料,大部分说粘贴的字符与实际生成的不一致,例如windows环境下,如果有换行习惯带"\r\n",去除即可.几次尝试都不可以. 最后发现是粘贴的内容有问题,只黏贴了密钥,没有前贴前面的“ssh-rsa” 和后面的邮箱. 谨记:要粘贴pub密钥里面的所有内容(

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

1.SSL认证 不需要特别配置,相关证书库生成看https认证中的相关部分 2.HTTPS认证 一.基本概念 1.单向认证,就是传输的数据加密过了,但是不会校验客户端的来源 2.双向认证,如果客户端浏览器没有导入客户端证书,是访问不了web系统的,找不到地址 如果只是加密,我感觉单向就行了. 如果想要用系统的人没有证书就访问不了系统的话,就采用双向 二.服务器配置: 打开Tomcat 根目录下的 /conf/server.xml 修改server.xml 客户端证书注册名称必须与域名一致,否则无

创建ssh秘钥在GitHub上配置公钥

原文地址:https://www.cnblogs.com/King-boy/p/11183240.html

利用OpenSSH实现基于秘钥的认证

利用OpenSSH实现基于秘钥的认证 SSH协议介绍:     SSH是Secure Shell的缩写,意思是安全的shell          目前版本有 ssh v1和ssh  v2:在目前工作中大多都使用ssh v2版,ssh  v1已经不安全,尽量不使用              ssh v1:基于CRC-----32做MAC(Message Authentication Code),不安全              ssh v2:基于双方主机的协商最安全的MAC的方式:基于DH算法做秘

使用SecureCRT秘钥登录服务器

ps: 红字字体为重要部分, 仔细看 为什么要使用SecureCRT秘钥登录? 简单理解为了安全. 比如说连接A服务器, SecureCRT相当于一把完整的锁. 把锁放在A服务器上, 钥匙放在本地.拿钥匙开锁. 1. 首先通过SSH协议22号端口连接A服务器, 然后创建"公钥". 2. 选择加密算法. 3. 设置秘钥密码, 选填(本案测试, 默认) 4. 设置秘钥长度, 默认即可. 5. 设置生产公钥保存的路径 6. 问我们是否使用秘钥为全局公钥 7. 看看我们刚才生成的秘钥文件. 8

GIT 生成秘钥操作

第一步: 你得有个Git,什么?你连Git都没有,那好,不用往下看了,泥奏凯 第二步: 打开Git Bash,什么?不知道打开,那好,你Git安装了吗?,好了,我知道了,泥奏凯 第n步: 欸,你居然没走,那好吧,你看吧 查看你是否有ssh秘钥文件 $ cd ~/.ssh 配置你的git,把你真实名字和真实邮箱写上去,这样,你写了烂代码的时候,人家可以顺着你的邮箱对你进行亲切的问候 $ git config --global user.name "name" //name改成你要的名字,

soapui测试https双向验证p12项目

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

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

本文我们将讲解一个Android产品研发中可能会碰到的一个问题:如何在App中保存静态秘钥以及保证其安全性.许多的移动app需要在app端保存一些静态字符串常量,其可能是静态秘钥.第三方appId等.在保存这些字符串常量的时候就涉及到了如何保证秘钥的安全性问题.如何保证在App中静态秘钥唯一且正确安全,这是一个很重要的问题,公司的产品中就存在着静态字符串常量类型的秘钥,所以一个明显的问题就是如何生成秘钥,保证秘钥的安全性? 现今保存静态秘钥的几种主流通用做法:(参考:Android安全开发之浅谈

OpenVPN 秘钥+用户名密码双重验证登录

为什么需要用户名密码验证登录 我们已经使用了CA证书.迪菲赫尔曼交换密钥.TLS-auth密钥这几种方式进行加密了, 可以说已经很安全了,为什么还要需要用户名秘密呢,一个VPN而已,搞得这么安全有什么用呢. 首先安全还是很重要的,其次就是管理这些秘钥和证书还是比较麻烦的,因为用户量比较多. 我不可能为每个用户都创建一套加密吧,每个用户创建一个秘钥比较麻烦, 多人使用一个秘钥又不具有唯一性,比如说有用户不在需要VPN的时候,我们就只能吊销证书. 但是如果多人使用一个秘钥的情况下,吊销证书了,其他的