Skip to the content.

Openstack CLI tutorial

Based on Openstack Stein

Mario David Jorge Gomes


Access to Openstack through the CLI

The openstack credentials for your user, so you can set the environment variables with:


This will set the following environment variables:


Testing the access to openstack

From here on you should be able to do the rest of the tutorial. Test with:

openstack project list

Create an ssh keypair

The access to VM instances is done through an ssh key pair, where your public key is inserted into the VM, when it is instantiated.

To create an ssh keypair, you should issue the following command:


By default it generates an RSA 2048 bit key that is stored in your $HOME/.ssh/ directory, you should set a strong passphrase

.ssh/id_rsa is your ssh private key, and .ssh/ is your ssh public key.

List keypairs

You can list all keypairs already in openstack:

openstack keypair list

The next step is to insert your ssh public key in openstack, you should be careful to choose a keypair name that does not yet exist:

openstack keypair create --public-key .ssh/ ${LOGNAME}-key

Instantiate a VM

In order to instantiate a VM, the following information is needed:

List images and choose one:

openstack image list

List flavors and choose one:

openstack flavor list

List all networks:

openstack network list

Create a virtual machine

Now you can create a server, note the name of the server should not exist, the list of servers can be checked with:

openstack server list

openstack server create --flavor svc1.s --key-name ${LOGNAME}-key --network tutorial_net --image centos7-x86_64-raw ${LOGNAME}-server

Check the status of VM

The status of the newly created server:

openstack server show ${LOGNAME}-server

Where the following attributes can be checked:

| OS-EXT-STS:power_state      | Running    |
| OS-EXT-STS:vm_state         | active     |

At this point the VM only has a private IP, and is not accessible from a public network:

| addresses  | tutorial_net= 

Associate a floating public IP with the VM

In the previous slide you have listed the available networks, it includes the public network called public_net, you can create a public IP with:

openstack floating ip create public_net

It will show in particular the attribute:

| floating_ip_address |

Get the server ID with:

openstack server show ${LOGNAME}-server -f value -c id

Associate floating IP to VM

Now you can associate the floating public IP with the server:

openstack server add floating ip <SERVER_ID>

Now you can confirm that this floating public IP has been associated to your VM:

openstack server show ${LOGNAME}-server

| addresses  | tutorial_net=,

Accessing the VM

Since the base image of the VM is Centos7, the default user is centos, for ubuntu base images the default user is ubuntu.

You can now access the VM with ssh:

ssh centos@


To delete the server:

openstack server delete u60-server