您好,登錄后才能下訂單哦!
小編給大家分享一下Linux中如何使用ssh-keygen命令,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
ssh-keygen命令用于為“ssh”生成、管理和轉換認證密鑰,它支持RSA和DSA兩種認證密鑰。
語法 ssh-keygen [-q] [-b bits] -t type [-N new_passphrase] [-C comment] [-f output_keyfile] ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile] ssh-keygen -i [-f input_keyfile] ssh-keygen -e [-f input_keyfile] ssh-keygen -y [-f input_keyfile] ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile] ssh-keygen -l [-f input_keyfile] ssh-keygen -B [-f input_keyfile] ssh-keygen -D reader ssh-keygen -F hostname [-f known_hosts_file] ssh-keygen -H [-f known_hosts_file] ssh-keygen -R hostname [-f known_hosts_file] ssh-keygen -U reader [-f input_keyfile] ssh-keygen -r hostname [-f input_keyfile] [-g] ssh-keygen -G output_file [-v] [-b bits] [-M memory] [-S start_point] ssh-keygen -T output_file -f input_file [-v] [-a num_trials] [-W generator]
-b:指定密鑰長度; -e:讀取openssh的私鑰或者公鑰文件; -C:添加注釋; -f:指定用來保存密鑰的文件名; -i:讀取未加密的ssh-v2兼容的私鑰/公鑰文件,然后在標準輸出設備上顯示openssh兼容的私鑰/公鑰; -l:顯示公鑰文件的指紋數據; -N:提供一個新密語; -P:提供(舊)密語; -q:靜默模式; -t:指定要創建的密鑰類型。
創建一個默認密鑰
[root@localhost ~]# ssh-keygen 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. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:QfclO+AvXZ/O6vGNfzo4P2pftiHRoKG2fgc5p9bvu1o root@localhost.localdomain The key's randomart image is: +---[RSA 2048]----+ | . o . . | | . o o + | | . ..+.. | | ..oooo..| | So..+. o.| | . .= .+ | | . *+ Eo| | . ++oO+=| | .o.+OO%*| +----[SHA256]-----+ [root@localhost ~]#
指定要創建的密鑰類型
[root@localhost ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): /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:nTaoqOxlG6IQQ2zDTMvSk2EON+4tLrYqPy7IBrstoy4 root@localhost.localdomain The key's randomart image is: +---[RSA 2048]----+ |..= | |*B.+ | |.X* | |+..o o . | |o o . S = | |.+ . . . . . | |*oo = . | |EBo= o | |%@B.. | +----[SHA256]-----+ [root@localhost ~]#
使用-t參數創建一個指定密鑰的類型并添加注釋
[root@localhost ~]# ssh-keygen -t rsa -C "deng@qq.com" Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): /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:Wx3MWwj36fwhcnb6hjdIIJ3SUggCLcmFq62Earqy2E0 deng@qq.com The key's randomart image is: +---[RSA 2048]----+ | ..*o .. o . | | = .. . * o . | | o + * + | | . + * * | |. o S =.++oo | |.o . o +.+..| |o . E . ..o .| |++ o o.+ | |Oo. . o..| +----[SHA256]-----+ [root@localhost ~]#
讀取openssh的私鑰或者公鑰文件
[root@localhost ~]# ssh-keygen -e Enter file in which the key is (/root/.ssh/id_rsa): ---- BEGIN SSH2 PUBLIC KEY ---- Comment: "2048-bit RSA, converted by root@localhost.localdomain from O" AAAAB3NzaC1yc2EAAAADAQABAAABAQCyQ/iZYPZHH7+4Gcfq259xChnidsf25piKsnRi+o /XZcD0s9QL8oX24OuX5pPQcmfD6Rw6sQCrTy66LrSw2NmPpKc0XdUbXEkLYBN4d3SY+ZLT 3Ot8L6jaDmwgXsBu8lTXzAEWLm+16RXAZAB/27ohi48PfcIDYyeJ1JDpieCJ1/a/KrR9V4 erWVBt/ZE8KoC0MTQlUn7H3oABVS9O6sdY4dYc/T9l33EbqZMc2feYZnuWtrPdrYfz37C+ kzg3ZrDojGXtiWk1p/PG5KoAH6GzuYYIuMtrUTnadRv4wZo29RF+n5Ty8HEeYqSceHWWvw Jjqnpqj9cgeNQvq6E3PJbD ---- END SSH2 PUBLIC KEY ---- [root@localhost ~]#
安靜模式生成密鑰對
[root@localhost ~]# ssh-keygen -q -t rsa Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): Enter same passphrase again: [root@localhost ~]#
以上是“Linux中如何使用ssh-keygen命令”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。