2014년 9월 10일 수요일

Connect VM instance by using SSH (key pair)

There are two ways to connect VM instance using SSH. One is the way of key pair and the other one is the config_init.

############################################
# Login to VM instance using key pair
############################################

1. Create a key pair in OpenStack
    ex) name : ubuntu-cloud

2. Download it to local PC (when you create a key pair in Horizontal GUI then it will automatically be downloaded.

3. Create a new VM instance in OpenStack with the key pair

4. Login to the VM instance using SSH as below
     # ssh -i ubuntu-cloud.pem ubuntu@192.168.100.102

##### INFO #####
- The permission of the key file should be 600. So change the mod of key file as below
# chmod 600 ./ubuntu-cloud.pem


############################################
# Login to VM instance using config_init
############################################

* Ref. #1 : http://docs.openstack.org/user-guide/content/user-data.html
* Ref. #2 : http://www.blog.sandro-mathys.ch/2013/07/setting-user-password-when-launching.html
* Ref. #3 : https://help.ubuntu.com/community/CloudInit


1. Put a custom script when create a VM instance in Horizon
1) Go to Post-Creation tab 
2) Insert the code below as a Customization Script. 
3) Hit the Launch button 
4) Once the instance is up, you should be able to log in with the configured password.

#cloud-config
password: ubuntu
chpasswd: { expire: False }
ssh_pwauth: True



############################################
# Login to CentOS VM instance using config_init
############################################

#cloud-config
chpasswd:
list: |
root:stackops
cloud-user:stackops
expire: False
ssh_pwauth: True

CentOS 7.0 images:

#cloud-config
chpasswd:
list: |
root:stackops
centos:stackops
expire: False
ssh_pwauth: True

댓글 1개: