Setting Up OpenStack Prerequisites for Launching Instances
Learn how to create SSH key pairs, configure security groups, and set up networks before launching your first OpenStack instance.
Introduction
Before you can launch your first OpenStack instance, you must configure several prerequisite components that provide secure access, network connectivity, and firewall rules. These one-time setup tasks create the infrastructure foundation for all your future instances.
This guide walks you through creating SSH key pairs for secure access, configuring security groups for firewall rules, and setting up networks for instance connectivity using both the Horizon dashboard and the OpenStack CLI.
What You Need Before Starting
Before configuring OpenStack prerequisites, ensure you have:
- An active InMotion Cloud account with a project created
- Access to the OpenStack Horizon dashboard
- OpenStack CLI installed and configured (for CLI methods)
- Basic understanding of SSH, firewall concepts, and networking
Creating SSH Key Pairs
SSH key pairs provide secure, password-free access to your instances. Each project should have at least one key pair, and you can create multiple key pairs for different use cases or team members.
Understanding Key Pairs
A key pair consists of:
- Private key: Stored securely on your local machine and never shared
- Public key: Injected into instances at launch time by cloud-init
When you create a key pair through Horizon, OpenStack generates both keys and provides the private key as a download. You are responsible for keeping this private key secure.
Creating a Key Pair Using Horizon
- Log in to your OpenStack Horizon dashboard
- Navigate to Project > Compute > Key Pairs
- Click Create Key Pair
- Enter a descriptive name for your key pair (example: "web-server-key")
- Select SSH Key as the key type
- Click Create Key Pair
The private key file (.pem format) downloads automatically to your computer. Save this file in a secure location. You cannot download it again.
Setting Correct Permissions on Private Key
Before using your private key, set the correct file permissions:
Linux/macOS:
1chmod 600 ~/Downloads/web-server-key.pem
Windows: Right-click the file, select Properties > Security, and ensure only your user account has read access.
Creating a Key Pair Using CLI
Generate a new key pair and save it locally:
1openstack keypair create web-server-key > ~/web-server-key.pem2chmod 600 ~/web-server-key.pem
Verify the key pair was created:
1openstack keypair list
Importing an Existing Public Key
If you already have an SSH key pair on your local machine, you can import the public key into OpenStack instead of generating a new pair.
Using Horizon:
- Navigate to Project > Compute > Key Pairs
- Click Import Public Key
- Enter a name for the key pair
- Paste your public key content or upload the public key file
- Click Import Public Key
Using CLI:
1openstack keypair create --public-key ~/.ssh/id_rsa.pub existing-key
Configuring Security Groups
Security groups act as virtual firewalls that control inbound and outbound traffic to your instances. Each instance must be assigned to at least one security group, and the default security group blocks all incoming traffic.
Understanding Security Group Rules
Security group rules define:
- Direction: Ingress (incoming) or egress (outgoing)
- Protocol: TCP, UDP, ICMP, or all protocols
- Port range: Specific ports (22 for SSH) or port ranges (8000-9000)
- Remote source: IP address ranges (CIDR notation) or other security groups
Creating a Security Group Using Horizon
- Navigate to Project > Network > Security Groups
- Click Create Security Group
- Enter a name (example: "web-server-sg")
- Add a description (example: "Allow SSH and HTTP/HTTPS traffic")
- Click Create Security Group
The new security group appears in the list and includes default egress (outbound) rules that allow all outgoing traffic.
Adding Rules to Security Groups Using Horizon
After creating a security group, add rules to allow specific traffic.
Allow SSH Access (Port 22):
- Click Manage Rules next to your security group
- Click Add Rule
- Select SSH from the Rule dropdown
- Set Remote to CIDR
- Enter 0.0.0.0/0 to allow SSH from any IP, or specify your IP range (example: 203.0.113.0/24)
- Click Add
Allow ICMP (Ping):
- Click Add Rule
- Select All ICMP from the Rule dropdown
- Set Remote to CIDR
- Enter 0.0.0.0/0
- Click Add
Allow HTTP Traffic (Port 80):
- Click Add Rule
- Select HTTP from the Rule dropdown
- Set Remote to CIDR
- Enter 0.0.0.0/0
- Click Add
Allow HTTPS Traffic (Port 443):
- Click Add Rule
- Select HTTPS from the Rule dropdown
- Set Remote to CIDR
- Enter 0.0.0.0/0
- Click Add
Creating Security Groups and Rules Using CLI
Create a new security group:
1openstack security group create web-server-sg --description "Allow SSH and HTTP/HTTPS traffic"
Add SSH rule:
1openstack security group rule create --protocol tcp --dst-port 22 --remote-ip 0.0.0.0/0 web-server-sg
Add ICMP rule:
1openstack security group rule create --protocol icmp web-server-sg
Add HTTP rule:
1openstack security group rule create --protocol tcp --dst-port 80 --remote-ip 0.0.0.0/0 web-server-sg
Add HTTPS rule:
1openstack security group rule create --protocol tcp --dst-port 443 --remote-ip 0.0.0.0/0 web-server-sg
List security group rules to verify:
1openstack security group show web-server-sg
Setting Up Networks
Networks provide IP connectivity for instances. Most OpenStack projects include a default network, but you may need to create additional networks for isolation or multi-tier architectures.
Understanding Network Components
OpenStack networks consist of:
- Network: A virtual isolated layer 2 broadcast domain
- Subnet: An IP address range (CIDR) within a network
- Router: Connects networks together and provides external connectivity
Verifying Existing Networks Using Horizon
Before creating new networks, check what already exists:
- Navigate to Project > Network > Networks
- Review the list of available networks
- Click on a network name to view its subnets and details
If you see a network with a subnet already configured, you can skip network creation and use the existing network when launching instances.
Creating a Network Using Horizon
If you need to create a new network:
- Navigate to Project > Network > Networks
- Click Create Network
- Enter a network name (example: "private-network")
- Click Next
Create Subnet:
- Enter a subnet name (example: "private-subnet")
- Enter network address in CIDR notation (example: 192.168.1.0/24)
- Select IP version (IPv4 or IPv6)
- Click Next
Configure Subnet Details:
- Enable DHCP (recommended)
- Optionally configure allocation pools (IP ranges available for instances)
- Enter DNS nameservers (example: 8.8.8.8, 8.8.4.4)
- Click Create
Creating a Network Using CLI
Create a network:
1openstack network create private-network
Create a subnet within the network:
1openstack subnet create --network private-network \2 --subnet-range 192.168.1.0/24 \3 --dns-nameserver 8.8.8.8 \4 --dns-nameserver 8.8.4.4 \5 private-subnet
Verify network creation:
1openstack network list2openstack subnet list
Connecting Networks to Routers
If your network needs external connectivity (internet access), connect it to a router.
Using Horizon:
- Navigate to Project > Network > Routers
- Click Create Router
- Enter a router name
- Select an external network for the gateway
- Click Create Router
- Click on the router name
- Select the Interfaces tab
- Click Add Interface
- Select your private subnet
- Click Submit
Using CLI:
1openstack router create my-router2openstack router set --external-gateway public my-router3openstack router add subnet my-router private-subnet
Verifying Prerequisites
Before launching your first instance, confirm all prerequisites are configured correctly.
Check Key Pairs
Horizon: Navigate to Project > Compute > Key Pairs and verify at least one key pair exists.
CLI:
1openstack keypair list
Check Security Groups
Horizon: Navigate to Project > Network > Security Groups and verify your security group has rules allowing SSH and ICMP.
CLI:
1openstack security group list2openstack security group show web-server-sg
Check Networks
Horizon: Navigate to Project > Network > Networks and verify at least one network with a subnet exists.
CLI:
1openstack network list2openstack subnet list
Next Steps
With prerequisites configured, you are ready to launch your first instance. Refer to the "Launching Your First Instance in OpenStack Horizon" guide for step-by-step instructions on creating and connecting to your instance.
Troubleshooting Common Issues
Cannot Download Private Key After Creation
Cause: The private key is only available for download once, immediately after creation.
Solution: Delete the key pair and create a new one, or import an existing public key from your local machine instead.
Security Group Rules Not Working
Cause: Rules may be configured incorrectly, or you may be testing from the wrong source IP.
Solution: Verify the CIDR range matches your source IP address:
1curl ifconfig.me
Use this IP in your security group rule, or use 0.0.0.0/0 for testing (restrict it later for security).
Network Has No Subnet
Cause: A network was created without a subnet.
Solution: Add a subnet to the existing network:
1openstack subnet create --network <network-name> \2 --subnet-range 192.168.1.0/24 \3 <subnet-name>
Cannot Access External Networks
Cause: Router is not connected to an external gateway or subnet.
Solution: Verify router configuration:
1openstack router show my-router
Ensure the external gateway is set and the private subnet is attached as an interface.
Related Resources
Related Articles
Launching Your First Instance in OpenStack Horizon
Step-by-step guide to launching your first virtual machine instance in OpenStack Horizon, from selecting an image to connecting via SSH.
Attaching Network Interfaces to OpenStack Instances
Learn how to attach additional network interfaces to running OpenStack instances using Horizon dashboard and CLI commands for multi-network configurations.
