Skip to main content

Remote Login of Instance in OpenStack

After successfully launching an instance via openstack dashboard,
you need to login in order to work with the instance.

Before login process, we have certain requirements to be satisfied.
This post discusses the steps required for login / remote login to an openstack instance.

Click here to know how an instance is accessed from public network in openstack

Remote Login Approach:

To enable remote login of instance, you have to:

(1) Associate Floating IP Address

(2) Attach Instance to Volume

(3) Login to the instance


(1) Associate Floating IP Address

1. Go to Project -> Compute -> Instances

2. In the list,  under the Actions of Cirros instance created, Click Associate Floating IP

3. In the Manage Floating IP Associations dialog, Click to allocate a new IP Address.


4. In the Allocate Floating IP dialog,  choose public pool.


5. Click Allocate IP

6. Select the Port to be associated. (The port would been in the list)

7. Click Associate.

8. In a few seconds, a floating IP address is allocated to the instance.

This floating IP is the unique instance access IP provided.


(2) Attach instance to the Volume


This procedure is for images / instances which have been created with sources without creating new volume.

Click here to know how to create volume in openstack

Click here to know how to create image in openstack

Click here to know how to launch instance in openstack


1. Go to Project -> Compute -> Instances

2. In the list,  under the Actions of Cirros instance created, there exists Create Snapshot dropdown

3. Click Attach Volume

4. Choose the Volume to be attached

5. You will receive a message for attaching instance

6. Go to Project -> Volume

7. Check the Volume selected, Status will turn In-Use and instance ID will be shown in Attached To


(3) Login to the instance

Cirros instance has a simple login. While other instances follow a different login.

Login for Cirros Instance:

The default image in openstack is Cirros. Since Cirros is a lightweight distribution of Linux, this instance can be used to check whether the process of launching instance has been done correctly without errors.

1. Go to Project -> Compute -> Instances

2. In the list,  under the Actions of Cirros instance created, there exists Create Snapshot dropdown.

3. Choose Console

4. You will enter a terminal with cirros username and password provided.


Login for Other Instances:

User can also create new images based on the OS of their choice:

Click to know how to create an image in openstack

But they follow a different procedure to remotely login to the instance.

1. Go to Project -> Compute -> Instances

2. In the list,  under the Actions of Cirros instance created, there exists Create Snapshot dropdown.

3. Choose Console

4.  You have 2 ways for login:

     Example:

     You have Ubuntu-Xenial-Server (Ubuntu 16.04) instance.
      Login: ubuntu.
      Key pair file name: newkey.pem
      Location: home/desktop
      Floating-ip of instance: xxx.xxx.xx.xx

     Way-1:  SSH Login:

     Before proceeding on ssh, click here to know how to add rule to security groups

     a. Locate the .pem file you saved while creating key pair.

          Click here to know how to create a key pair in openstack

     b. In your host terminal, use the command:
 
          ssh -i  home/desktop/newkey.pem ubuntu@xxx.xxx.xx.xx

        The prompt changes to: ubuntu@xxx.xxx.xx.xx $

         Execute the following commands:
   
         (i) Elevate Priviliges: sudo su - 
         (ii) Create new user: useradd -G sudo -U -m username
         (iii) Create password: passwd username  
                                            (Enter password and confirm password)
         (iv) Open ‘/etc/ssh/sshd_config’ and set the following parameters
                 ChallengeResponseAuthentication yes
                  PasswordAuthentication yes
          (v) To enable root login: PermitRootLogin yes
          (vi) To set root password: passwd
                                                    (Enter password and confirm password)
          (vii) Restart sshd service: service ssh restart
        
          After this, you will not need the newkey.pem file to login again.
          You can either login as root user or with newly created user username with the respective password created.

     Way-2: Login via Password in Configuration script

      When we launched instance, we added a configuration script:

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

       Login via this username and password.


                 


Comments