linux rsa密钥生成工具,[linux]Ubuntu18.04生成RSA密钥

生成RSA密钥

1. 制作密钥对

[root@host ~]$ ssh-keygen <== 建立密钥对

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): <== 按 Enter

Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase): <== 输入密钥锁码,或直接按 Enter 留空

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:

0f:d3:e7:1a:1c:bd:5c:03:f1:19:f1:22:df:9b:cc:08 root@host

密钥锁码在使用私钥时必须输入,这样就可以保护私钥不被盗用。当然,也可以留空,实现无密码登录。

现在,在 root 用户的家目录中生成了一个 .ssh 的隐藏目录,内含两个密钥文件。id_rsa 为私钥,id_rsa.pub 为公钥。这时需要把id_rsa私钥文件取回本地备用。

2. 在服务器上安装公钥

键入以下命令,在服务器上安装公钥:

[root@host ~]$ cd .ssh

[root@host .ssh]$ cat id_rsa.pub >> authorized_keys

如此便完成了公钥的安装。为了确保连接成功,请保证以下文件权限正确:

[root@host .ssh]$ chmod 600 authorized_keys

[root@host .ssh]$ chmod 700 ~/.ssh

3. 设置SSH,打开密钥登陆功能

编辑 /etc/ssh/sshd_config 文件,搜索以下指令并进行如下设置:

PasswordAuthentication no

ChallengeResponseAuthentication no

UsePAM no

4. 保存文件并重启SSH服务

sudo systemctl restart ssh

标签:私钥,RSA,host,密钥,linux,Ubuntu18.04,root,id,ssh

来源: https://www.cnblogs.com/Swetchine/p/14670528.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值