基于秘钥的登录认证

ssh-keygen

ssh-keygen 是Unix和类Unix计算机系统上的安全外壳(SSH)协议套件的标准组件,用于通过使用各种加密技术在不安全的网络上建立远程计算机之间的安全shell会话。ssh-keygen实用程序用于生成,管理和转换身份验证密钥。

ssh-keygen能够使用三种不同的数字签字算法之一生成密钥。

在ssh-keygen工具的帮助下,用户可以为任何这些密钥类型创建密码(为了提供无人值守操作,密码可以保留为空,风险更高)。

这些密钥与相关工具 GNU Privacy Guard使用的密钥不同。
[[email protected] ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): #按Enter
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y   #覆盖之前的秘钥对
Enter passphrase (empty for no passphrase): #输入秘钥密码
Enter same passphrase again:           #重复
Your identification has been saved in /root/.ssh/id_rsa. #私钥
Your public key has been saved in /root/.ssh/id_rsa.pub.  #公钥
The key fingerprint is:
SHA256:zrHfkb0+zCDc3/BKUvpILyHMwruqyhw8ZQy+CoFROWM [email protected]
The key‘s randomart image is:
+---[RSA 2048]----+
|  ..             |
| .E              |
|...o             |
|.o o             |
|o . +  .S+ .  .  |
| o +   ooo* +=.  |
|. =     +o o**o+ |
|.+ o    .. o.B=.o|
|. +........ oo*o |
+----[SHA256]-----+
[[email protected] ~]# 

ssh-copy-id

使用本地可用密钥来授权远程计算机上的登录
[[email protected] .ssh]# ssh-copy-id -i id_rsa.pub [email protected]127.0.0.1     #通过ssh-copy-id 工具将秘钥对发送到服务器,这里我是本机测试,或者可以使用cat 命令直接重定向
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "id_rsa.pub"
/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
[email protected]127.0.0.1‘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]# 

Xshell 配置

测试可以正常登录,如果登录异常请检查 /etc/ssh/sshd_config 配置文件对应参数

原文地址:https://www.cnblogs.com/zy09/p/10784136.html

时间: 2024-08-30 00:07:06

基于秘钥的登录认证的相关文章

SecureCRT基于秘钥来登录

在windows端生成密钥,客户端连接是使用SecureCRT 工具 –>创建公钥 生成密钥后,把公钥文件复制到服务器端对应用户家目录的.ssh目录下,文件名字为authorized_keys,记住此权限给其为400. 把Identity.pub公钥文件复制到服务器端 若root家目录下没有.ssh目录,在服务器端root家目录下新建.ssh目录 #mkdir .ssh #cat Identity.pub >> .ssh/authorized_keys #chmod –R 400 .ss

利用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算法做秘

使用秘钥对登录服务器

一. 使用秘钥对登录服务器 登录服务器的方式,可以使用用户名/密码的方式登录.也可以使用秘钥对的方式登录.在阿里云服务器上一般都建议使用密钥对的方式登录,并且是普通用户.下面就介绍一下如何使用秘钥对的方式登录服务器. 1. 使用root用户创建普通用用户并构建秘钥对 [[email protected] ~]# useradd lzc [[email protected] ~]# su - lzc   // 这里非常重要,要切换成普通用户.为了避免后续修改权限等问题 [[email protec

Linux 秘钥对登录远程主机

需要两台电脑,IP地址分别是:服务端:192.168.1.182客户端:192.168.1.183配置秘钥对登录远程主机 客户端主机生产秘钥 A.生产秘钥[[email protected] ~]# ssh-keygen -t rsa B.推送秘钥到服务端主机[[email protected] ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] C.用钥匙登录试试[[email protected] ~]# ssh [email

基于jwt的用户登录认证

最近在app的开发过程中,做了一个基于token的用户登录认证,使用vue+node+mongoDB进行的开发,前来总结一下. token认证流程: 1:用户输入用户名和密码,进行登录操作,发送登录信息到服务器端. 2:服务器端查询数据库验证用户名密码是否正确,正确,通过jsonwebtoken生成token,返回给客户端:否则返回错误信息给客户端. 3:通过本地存储存储获取的token信息,并且会跳转到路由指定的页面. 4:当客户端需要请求数据时,发送请求,并且在请求的头文件中添加本地存储的t

Linux ssh服务开启秘钥和密码认证

问题描述: 实现Linux秘钥和密码同时认证 解决方案: vim /etc/ssh/sshd_config 基本参数: PermitRootLogin yes #允许root认证登录 PasswordAuthentication yes #允许密码认证 RSAAuthentication yes #秘钥认证 PubkeyAuthentication yes 详细参数列表 [[email protected] ~]# cat /etc/ssh/sshd_config # $OpenBSD: ssh

putty秘钥验证登录和xshell秘钥验证登录

使用putty进行秘钥登录 1:先使用putty链接上服务器,确保正常登录 2: 3:打开puttygen软件,如图 4:把公钥复制粘贴到vim /root/.ssh/authorized_keys 5:在putty端进行更改 6:登录即可

linux ssh秘钥配置登录

#ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa):  Enter passphrase (empty for no passphrase):  Enter same passphrase again:  Your identification has been saved in /root/.ssh/id_rsa. Y

linux系统下ssh免秘钥登录

我有两台linux主机: 主机名分别是: lsx01.com lsx02.com 希望在lsx01.com这台主机上无秘钥登录lsx02.com. 一.修改hosts文件 在两台机器上都添加主机ip信息 例如在lsx01.com上: vi /etc/hosts 配置如下: 二.生成rsa秘钥文件,统一拷贝至一个authorized_keys中 1.在所有主机上,例如lsx01.com主机上生成rsa秘钥文件 cd /root/.ssh ssh-keygen -t rsa 三下回车 生成了两个文件