next up previous contents
Next: Security Group Rules Up: Instance Previous: 新增 flavor   Contents

登入金鑰對

  1. 載入用戶 demo 的環境變數。
    [root@controller ~]# . demo.token
    
  2. 如果 .ssh 目錄沒有金鑰對,就先執行 ssh-keygen 產生。
    [root@controller ~]# ssh-keygen -q -N ""
    Enter file in which to save the key (/root/.ssh/id_rsa): ^C
    [root@controller ~]# ll .ssh/
    total 16
    -r--------. 1 root root  788 May 22 17:50 authorized_keys
    -rw-------. 1 root root 1675 May 22 17:50 id_rsa
    -rw-r--r--. 1 root root  392 May 22 17:50 id_rsa.pub
    -rw-r--r--. 1 root root 1139 May 22 19:25 known_hosts
    
  3. 將 public key 加到 openstack,設定名為 mykey。
    [root@controller ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
    +-------------+-------------------------------------------------+
    | Field       | Value                                           |
    +-------------+-------------------------------------------------+
    | fingerprint | 2d:0a:a2:58:e1:e7:f6:bd:55:c8:6f:27:9d:64:be:d9 |
    | name        | mykey                                           |
    | user_id     | 0d7bb3820384452abb97ec0b40c445b1                |
    +-------------+-------------------------------------------------+
    
  4. 確認 openstack 有 mykey 的金鑰對。
    [root@controller ~]# openstack keypair list
    +-------+-------------------------------------------------+
    | Name  | Fingerprint                                     |
    +-------+-------------------------------------------------+
    | mykey | 2d:0a:a2:58:e1:e7:f6:bd:55:c8:6f:27:9d:64:be:d9 |
    +-------+-------------------------------------------------+
    



2018-09-19