ssh-keygen
Contents
ssh-keygen, linux 生成 ssh 密钥
ssh-keygen 是用于为 SSH 创建新的身份验证密钥对的工具。此类密钥对用于自动登录,单点登录和验证主机。 目前广泛的用在 linux 服务验证、git 身份验证上。
执行 ssh-keygen 可以生成一个密钥对, 这个密钥对称为公钥文件和私钥文件 ,例如:
使用 rsa 算法:id_rsa(私钥), id_rsa.pub(公钥) 使用 dsa 算法:id_dsa(私钥), id_dsa.pub(公钥)
在 ~/.ssh 目录下生成私钥 id_rsa 和公钥 id_rsa.pub 文件
|
|
推送公钥到服务器
|
|
print SHA256 fingerprint
|
|
|
|
public key file: authorized_keys
this command will generating public/private rsa key pair.
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED
|
|
multiple ssh private keys
by Karanbir Singh
http://www.karan.org/blog/index.php/2009/08/25/multiple-ssh-private-keys
In quite a few situations its preferred to have ssh keys dedicated for a service or a specific role. Eg. a key to use for home / fun stuff and another one to use for Work things, and another one for Version Control access etc. Creating the keys is simple, just use
ssh-keygen -t rsa -f ~/.ssh/id_rsa.work -C “Key for Word stuff”
Use different file names for each key. Lets assume that there are 2 keys, ~/.ssh/id_rsa.work and ~/.ssh/id_rsa.misc . The simple way of making sure each of the keys works all the time is to now create config file for ssh:
touch ~/.ssh/config chmod 600 ~/.ssh/config echo “IdentityFile ~/.ssh/id_rsa.work” » ~/.ssh/config echo “IdentityFile ~/.ssh/id_rsa.misc” » ~/.ssh/config
This would make sure that both the keys are always used whenever ssh makes a connection. However, ssh config lets you get down to a much finer level of control on keys and other per-connection setups. And I recommend, if you are able to, to use a key selection based on the Hostname. My ~/.ssh/config looks like this :
|
|
Ofcourse, if I am connecting to a remote host that does not match any of these selections, ssh will default back to checking for and using the ‘usual’ key, ~/.ssh/id_dsa or ~/.ssh/id_rsa
作者:Martain 链接:https://www.jianshu.com/p/75bf863c4ab6 来源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Author -
LastMod 2011-11-24