Install Keystone
Overview
Keystone is the identity service of OpenStack. It handles authentication and authorization for all other services. The steps include:
- Configure SQL database
- Install required packages
- Update keystone.conf
- Initialize Keystone
- Configure Apache
Each step builds the identity service, which is the core access control of OpenStack.
NOTES: The hostnames of all the nodes in this lab are configured in the /etc/hosts file in each node (See Networking and Security).
Lab diagram:

Configure MySQL Database
Start by preparing the database for Keystone. Log in as root on the controller node.
-
Loging to MySQL:
sudo mysql -
Create the database:
CREATE DATABASE keystone;Output:
Query OK, 1 row affectedinfoAlways end MySQL commands with a semicolon.
-
Grant privileges to the
keystoneuser for local access:GRANT ALL PRIVILEGES ON keystone.- TO 'keystone'@'localhost' IDENTIFIED BY 'openstack';Output:
Query OK, 0 row affected -
Grant privileges for remote access:
GRANT ALL PRIVILEGES ON keystone.- TO 'keystone'@'%' IDENTIFIED BY 'openstack';Output:
Query OK, 0 row affected -
Exit the database:
exit
The database is now ready for Keystone, which completes the backend setup for identity management.
Install Required Packages
Install Keystone and its dependencies. Keystone runs as a WSGI module under Apache.
apt install -y keystone apache2 libapache2-mod-wsgi-py3 crudini
Packages installed:
- Keystone for identity management
- Apache2 as the HTTP server
- WSGI module for integration
- Crudini for easier configuration editing
After installation, the system is ready for configuration.
Configure Keystone Database Access
The main configuration file is:
/etc/keystone/keystone.conf
In this setup, we can use crudini to set the database connection in the [database] section.
This command sets the connection parameter:
crudini --set /etc/keystone/keystone.conf \
database connection mysql+pymysql://keystone:openstack@controller/keystone
Here, the openstack is the password:
keystone:openstack
Output: No visible output if successful.
This connects Keystone to the MySQL database created earlier.
Configure Token Provider
Set the token provider to fernet in the [token] section:
crudini --set /etc/keystone/keystone.conf token provider fernet
Output: No visible output if successful.
Fernet is the recommended token provider for secure identity tokens. This completes the main Keystone configuration.
Initialize Keystone
Populate the database using the keystone-manage tool.
-
Run the database sync as the
keystoneuser:su -s /bin/sh -c "keystone-manage db_sync" keystone -
Initialize Fernet keys:
keystone-manage fernet_setup \--keystone-user keystone \--keystone-group keystone -
Initialize credential keys:
keystone-manage credential_setup \--keystone-user keystone \--keystone-group keystone -
Bootstrap the identity service with admin credentials.
keystone-manage bootstrap \--bootstrap-password openstack \--bootstrap-admin-url http://controller:5000/v3/ \--bootstrap-internal-url http://controller:5000/v3/ \--bootstrap-public-url http://controller:5000/v3/ \--bootstrap-region-id RegionOneThis command sets:
- Admin password (
openstack) - Admin URL (port 35357) --> Use 5000
- Internal URL (port 5000)
- Public URL (port 5000)
- Region name
UPDATE: In modern deployments, port 35357 is not actually used anymore. Port 5000 is used for everything (public, internal, admin). If you use port 35357 for the admin URL, it will only create the endpoint records in the Keystone database but it will NOT configure Apache or bind Keystone to port 35357.
You can verify this by running in the controller node:
ss -ltnp | grep 35357If this shows nothing, then Keystone is NOT listening there.
- Admin password (
Keystone is now initialized and ready to serve identity requests.
Configure Apache Server
Keystone runs through Apache. Set the ServerName in the Apache configuration file.
sudo vi /etc/apache2/apache2.conf
Add this line under global configuration:
#ServerRoot "/etc/apache2"
ServerName controller
Restart Apache:
sudo systemctl restart apache2
sudo systemctl status apache2
Keystone is now active and accessible via Apache. The identity service is fully installed and ready to authenticate OpenStack services.
Client Environment Scripts
Keystone is installed and the admin user exists. Now we prepare environment scripts so the OpenStack CLI can authenticate properly.
- Create one script per user
- Set required OS environment variables
- Secure the file because it contains passwords
Make sure to load the correct variables so the CLI can talk to Keystone correctly.
Create Admin Environment Script
First, create a script named admin-openrc in the home directory. This file is used for management tasks and will export the following variables:
cat > admin-openrc.sh <<EOF
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
EOF
In the example above:
OS_PASSWORDis the admin password set during bootstrapOS_AUTH_URLuses the admin endpoint on port5000.
Restrict access because the password is stored in plain text.
chmod 600 admin-openrc.sh
This protects your credentials and completes the admin environment setup.