Linux中如何使用ssh-keygen命令
小编给大家分享一下Linux中如何使用ssh-keygen命令,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
Linux常用命令ssh-keygen命令用于为“ssh”生成、管理和转换认证密钥,它支持RSA和DSA两种认证密钥。
命令格式语法ssh-keygen[-q][-bbits]-ttype[-Nnew_passphrase][-Ccomment][-foutput_keyfile]ssh-keygen-p[-Pold_passphrase][-Nnew_passphrase][-fkeyfile]ssh-keygen-i[-finput_keyfile]ssh-keygen-e[-finput_keyfile]ssh-keygen-y[-finput_keyfile]ssh-keygen-c[-Ppassphrase][-Ccomment][-fkeyfile]ssh-keygen-l[-finput_keyfile]ssh-keygen-B[-finput_keyfile]ssh-keygen-Dreaderssh-keygen-Fhostname[-fknown_hosts_file]ssh-keygen-H[-fknown_hosts_file]ssh-keygen-Rhostname[-fknown_hosts_file]ssh-keygen-Ureader[-finput_keyfile]ssh-keygen-rhostname[-finput_keyfile][-g]ssh-keygen-Goutput_file[-v][-bbits][-Mmemory][-Sstart_point]ssh-keygen-Toutput_file-finput_file[-v][-anum_trials][-Wgenerator]常用选项
-b:指定密钥长度;-e:读取openssh的私钥或者公钥文件;-C:添加注释;-f:指定用来保存密钥的文件名;-i:读取未加密的ssh-v2兼容的私钥/公钥文件,然后在标准输出设备上显示openssh兼容的私钥/公钥;-l:显示公钥文件的指纹数据;-N:提供一个新密语;-P:提供(旧)密语;-q:静默模式;-t:指定要创建的密钥类型。参考示例
创建一个默认密钥
[root@localhost~]#ssh-keygenGeneratingpublic/privatersakeypair.Enterfileinwhichtosavethekey(/root/.ssh/id_rsa):Enterpassphrase(emptyfornopassphrase):Entersamepassphraseagain:Youridentificationhasbeensavedin/root/.ssh/id_rsa.Yourpublickeyhasbeensavedin/root/.ssh/id_rsa.pub.Thekeyfingerprintis:SHA256:QfclO+AvXZ/O6vGNfzo4P2pftiHRoKG2fgc5p9bvu1oroot@localhost.localdomainThekey'srandomartimageis:+---[RSA2048]----+|.o..||.oo+||...+..||..oooo..||So..+.o.||..=.+||.*+Eo||.++oO+=||.o.+OO%*|+----[SHA256]-----+[root@localhost~]#
指定要创建的密钥类型
[root@localhost~]#ssh-keygen-trsaGeneratingpublic/privatersakeypair.Enterfileinwhichtosavethekey(/root/.ssh/id_rsa):/root/.ssh/id_rsaalreadyexists.Overwrite(y/n)?yEnterpassphrase(emptyfornopassphrase):Entersamepassphraseagain:Youridentificationhasbeensavedin/root/.ssh/id_rsa.Yourpublickeyhasbeensavedin/root/.ssh/id_rsa.pub.Thekeyfingerprintis:SHA256:nTaoqOxlG6IQQ2zDTMvSk2EON+4tLrYqPy7IBrstoy4root@localhost.localdomainThekey'srandomartimageis:+---[RSA2048]----+|..=||*B.+||.X*||+..oo.||oo.S=||.+.....||*oo=.||EBo=o||%@B..|+----[SHA256]-----+[root@localhost~]#
使用-t参数创建一个指定密钥的类型并添加注释
[root@localhost~]#ssh-keygen-trsa-C"deng@qq.com"Generatingpublic/privatersakeypair.Enterfileinwhichtosavethekey(/root/.ssh/id_rsa):/root/.ssh/id_rsaalreadyexists.Overwrite(y/n)?yEnterpassphrase(emptyfornopassphrase):Entersamepassphraseagain:Youridentificationhasbeensavedin/root/.ssh/id_rsa.Yourpublickeyhasbeensavedin/root/.ssh/id_rsa.pub.Thekeyfingerprintis:SHA256:Wx3MWwj36fwhcnb6hjdIIJ3SUggCLcmFq62Earqy2E0deng@qq.comThekey'srandomartimageis:+---[RSA2048]----+|..*o..o.||=...*o.||o+*+||.+**||.oS=.++oo||.o.o+.+..||o.E...o.||++oo.+||Oo..o..|+----[SHA256]-----+[root@localhost~]#
读取openssh的私钥或者公钥文件
[root@localhost~]#ssh-keygen-eEnterfileinwhichthekeyis(/root/.ssh/id_rsa):----BEGINSSH2PUBLICKEY----Comment:"2048-bitRSA,convertedbyroot@localhost.localdomainfromO"AAAAB3NzaC1yc2EAAAADAQABAAABAQCyQ/iZYPZHH7+4Gcfq259xChnidsf25piKsnRi+o/XZcD0s9QL8oX24OuX5pPQcmfD6Rw6sQCrTy66LrSw2NmPpKc0XdUbXEkLYBN4d3SY+ZLT3Ot8L6jaDmwgXsBu8lTXzAEWLm+16RXAZAB/27ohi48PfcIDYyeJ1JDpieCJ1/a/KrR9V4erWVBt/ZE8KoC0MTQlUn7H3oABVS9O6sdY4dYc/T9l33EbqZMc2feYZnuWtrPdrYfz37C+kzg3ZrDojGXtiWk1p/PG5KoAH6GzuYYIuMtrUTnadRv4wZo29RF+n5Ty8HEeYqSceHWWvwJjqnpqj9cgeNQvq6E3PJbD----ENDSSH2PUBLICKEY----[root@localhost~]#
安静模式生成密钥对
[root@localhost~]#ssh-keygen-q-trsaEnterfileinwhichtosavethekey(/root/.ssh/id_rsa):/root/.ssh/id_rsaalreadyexists.Overwrite(y/n)?yEnterpassphrase(emptyfornopassphrase):Entersamepassphraseagain:[root@localhost~]#
以上是“Linux中如何使用ssh-keygen命令”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。