登陆OS系统可以使用密码登录或者密钥登陆,密码登录是比较常见的一种方式,用户在操作系统中创建了用户名和密码,就可以使用自己的用户名和密码登录进去了;使用密钥登陆是另外一种方式,即用户创建一个密钥对(公钥和私钥),然后将公钥注入到OS中,在登陆时使用私钥校验,校验通过后就可以登入到OS。OpenStack提供了密钥登陆的功能,可以采用密钥注入或者文件注入的方式将公钥注入到OS中,本文采用了密钥注入的方式,以下是操作步骤。
1.生成密钥对
#cd /root/.ssh/
#ssh-keygen -t rsa
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回车
Enter same passphrase again: #Enter回车
Your identification has been saved in/root/.ssh/id_rsa. #Enter回车
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
a0:c6:df:8c:1f:a6:57:62:70:3f:4d:b7:cc:e4:5f:71 [MD5]root@08592946-A8B7-11A5-8567-000000821800
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| . |
| . .... . o.E|
| + oS. o * .o|
| . . +o + . = .|
| o.=o . ..|
| +.. .|
| ... |