ssh密钥的生成与使用
一客户端是linux
1.在客户端生成密钥对
[root@localhost ~]# ssh-keygen -t rsa <== 建立密钥对,-t代表类型,有RSA和DSA两种 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: SHA256:K1qy928tkk1FUuzQtlZK+poeS67vIgPvHw9lQ+KNuZ4 [email protected] The key's randomart image is: +---[RSA 2048]----+ | +. | | o * . | | . .O + | | . *. * | | S =+ | | . =... | | .oo =+o+ | | ==o+B*o. | | oo.=EXO. | +----[SHA256]-----+ --------------------- 版权声明:本文为CSDN博主「独孤柯灵」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/u014721096/article/details/78553032
密钥锁码在使用私钥时必须输入,这样就可以保护私钥不被盗用。当然,也可以留空,实现无密码登录,这里密钥锁码设置为空。完成上述步骤后,在root用户的家目录中生成了一个.ssh的隐藏目录,内含两个密钥文件,其中id_rsa为私钥,id_rsa.pub为公钥。
复制生成的公钥到远程主机里面~/.ssh/authorized_keys文件中。如果没有.ssh目录,需要自己建立一个,并更改目录权限为700
[root@localhost ~]# mkdir ~/.ssh [root@localhost ~]# chmod 700 ~/.ssh/ [root@localhost ~]# vim ~/.ssh/authorized_keys
相关推荐
projava 2020-11-14
WanKaShing 2020-11-12
airfish000 2020-09-11
tryfind 2020-09-14
yegen00 2020-09-10
kkaazz 2020-09-03
风语者 2020-09-02
BraveWangDev 2020-08-19
lichuanlong00 2020-08-15
gsl 2020-08-15
pandaphinex 2020-08-09
yhuihon 2020-08-09
CheNorton 2020-08-02
xiangqiao 2020-07-28
hpujsj 2020-07-26
hpujsj 2020-07-26
sshong 2020-07-19
BraveWangDev 2020-07-19
annan 2020-07-18