基于秘钥的登录认证

ssh-keygen

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

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

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

这些密钥与相关工具 GNU Privacy Guard使用的密钥不同。

 

 

[root@localhost ~]# 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 root@localhost.localdomain
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]-----+
[root@localhost ~]# 

 

 

ssh-copy-id 

使用本地可用密钥来授权远程计算机上的登录

 

 

[root@localhost .ssh]# ssh-copy-id -i id_rsa.pub root@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
root@127.0.0.1's password: 

Number of key(s) added: 1

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

[root@localhost .ssh]# 

 

 

Xshell 配置

 

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

 

转载于:https://www.cnblogs.com/zy09/p/10784136.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值