Configuring SingleStoreDB for Kerberos Authentication
On this page
Once you have generated an SPN and a keytab file on the Kerberos KDC server, you can configure SingleStoreDB to allow access for Kerberos-authenticated users.
Depending on your SingleStoreDB cluster configuration, the SPN and keytab file may need to be configured on one or many aggregator nodes.
The following steps describe how to use the SPN and keytab file created earlier.
Copying the Keytab File to SingleStoreDB
A keytab file is a credential that can be used to access network resources, so it is important to consider the security implications of copying it from one location to another.
Use a secure file transfer method, such as scp
, to copy the keytab file from the KDC server to each SingleStoreDB aggregator node.memsql.
file in the next step.
Configuring memsql. cnf
Before Kerberos-authenticated users can connect to SingleStoreDB, you must configure each SingleStoreDB aggregator node’s memsql.
file with two variables:
-
gssapi-keytab-path
: The local path to the keytab file that was created on the KDC server and copied to the node.For example: /path/to/memsql.
keytab -
gssapi-principal-name
: The SPN for SingleStoreDB that was created on the KDC server.For example: memsql/host.
domain. com@DOMAIN. COM
Note
You cannot use the SET GLOBAL VARIABLE
command when setting these variables.memsql.
file on the applicable node using the steps described below.
To set these variables in the memsql.
file:
-
Ensure that the cluster is stopped before continuing.
-
Open the aggregator node’s
memsql.
file in a text editor (typical location for this file).cnf -
Add the following line to the file anywhere below the
[server]
declaration:[server]...gssapi-keytab-path = /path/to/memsql.keytabgssapi-principal-name = memsql/host.domain.com@DOMAIN.COM... -
Save the file.
-
Repeat this process for each aggregator node’s
memsql.
file.cnf -
After the
memsql.
file has been updated for each aggregator node in the cluster, start the cluster.cnf -
Verify that the change was successful by executing the following command on one of the affected nodes:
SHOW GLOBAL VARIABLES LIKE 'gssapi%';+-----------------------+-------------------------------------+ | Variable_name | Value | +-----------------------+-------------------------------------+ | gssapi_keytab_path | /path/to/memsql.keytab | | gssapi_principal_name | memsql/host.domain.com@DOMAIN.COM | +-----------------------+-------------------------------------+ 2 rows in set (0.00 sec)
Granting a User Kerberos Authentication Permissions
Now that the SingleStoreDB cluster has been configured, you can use the GRANT command to create a Kerberos-authenticated user and grant permissions.
Mapping a Single Kerberos Identity
The following example creates a new SingleStoreDB user ('user1'@'%'
) authenticating via Kerberos on all databases, where the Kerberos SPN is user1@EXAMPLE.
:
GRANT ALL ON *.* TO 'user1'@'%' IDENTIFIED WITH 'authentication_gss' AS 'user1@EXAMPLE.COM';
When this command is run, the 'user1'@'%'
SingleStoreDB user is created and mapped to the user1@EXAMPLE.
Kerberos SPN.'user1'@'%'
will require a Ticket Granting Ticket (TGT) from the KDC server for the user1@EXAMPLE.
SPN.
Note
The recommended way to create users is through the CREATE USER
command.IDENTIFIED WITH
clause.
GRANT DELETE ON db.* TO steve;
Mapping with Regular Expressions
You may also use regular expressions in the AS
clause of the GRANT
statement.
Caution
When using a regular expression in a GRANT
statement, confirm that the expression evaluates in an expected manner.
Regular expressions can only be used in the AS
clause of the GRANT
statement.AS
clause.
To enable regular expressions support, the first character in your AS
clause must start with a forward slash (/
).^
(start of line) and $
(end of line) operators to indicate when the regular expression should start and end.
Consider the following example that creates a new user:
GRANT ALL ON *.* to 'user1'@'%' IDENTIFIED WITH 'authentication_gss' AS '/^user1@EXAMPLE\.COM$';
This example creates the user via regular expression to match the user1@EXAMPLE.
string in any Kerberos SPN that attempts to authenticate with SingleStoreDB.user1@EXAMPLE.
SPN will be matched.
GRANT ALL ON *.* to 'user1'@'%' IDENTIFIED WITH 'authentication_gss' AS '/user1@EXAMPLE\.COM$';
The example above differs from the previous example by omitting the ^
start of line operator.user1@EXAMPLE.
, such as other_
.
Always ensure that your regular expression produces the intended result.
Example: Optional Subdomain
The following example creates the SingleStoreDB user 'user1'@'%'
with a Kerberos SPN that contains an optional subdomain.
GRANT ALL ON *.* to 'user1'@'%' IDENTIFIED WITH 'authentication_gss' AS '/^user1@(SUBDOMAIN\.)?EXAMPLE\.COM$';
Example: Optional Domain Suffix
The following example creates the SingleStoreDB user 'user1'@'%'
with a Kerberos SPN across domains with different suffixes, namely .
, .
, or .
.
GRANT ALL ON *.* to 'user1'@'%' IDENTIFIED WITH 'authentication_gss' AS '/^user1@EXAMPLE\.(COM|NET|ORG)$';
Connecting to SingleStoreDB as a Kerberos-authenticated User
After a SingleStoreDB user has been associated with a Kerberos SPN, you can connect to SingleStoreDB as that user.kinit
from the terminal.
Option 1: Use the SingleStore Client
Install the SingleStore client via the following instructions.
Install SingleStore Client
Red Hat Distribution
Online Installation
For online installations where the target host can access the SingleStore YUM repository, perform the following steps.
Note: These steps are also provided in the self-managed deployment guides.
-
Add the SingleStore repository to your repository list.
sudo yum-config-manager --add-repo https://release.memsql.com/production/rpm/x86_64/repodata/memsql.repo -
Verify that the SingleStore repo information is listed under
repolist
.sudo yum repolist -
Verify that the
which
package installed.This is used during the install process to identify the correct package type for your installation. rpm -q whichIf
which
is not installed, it must be installed before proceeding.If you cannot install
which
, you will have to specify the correct package during the deployment phase covered in the respective deployment guide.sudo yum install -y which -
Install the SingleStore client.
sudo yum install -y singlestore-client
Offline Installation
For clusters that must be deployed in an environment without Internet access, download the SingleStore client package onto a host that can access the main deployment host.
Copy the SingleStore client package onto the target host (typically the main deployment host when deploying SingleStoreDB) and install the SingleStore client.
sudo rpm -ivh /tmp/singlestore-client-<version>-<commit-hash>.x86_64.rpm
Debian Distribution
Online Installation
For online installations where the target host can access the SingleStore APT repository, perform the following steps.
Note: These steps are also provided in the self-managed deployment guides.
-
SingleStore packages are signed to ensure integrity, so the GPG key needs to be added to this host.
When done, verify that the SingleStore signing key has been added using apt-key list
.wget -O - 'https://release.memsql.com/release-aug2018.gpg' 2>/dev/null | sudo apt-key add - && apt-key list -
Verify that
apt-transport-https
is installed.apt-cache policy apt-transport-httpsIf
apt-transport-https
is not installed, it must be installed before proceeding.user-shell sudo apt -y install apt-transport-https -
Add the SingleStore repository to retrieve its packages.
echo "deb [arch=amd64] https://release.memsql.com/production/debian memsql main" | sudo tee /etc/apt/sources.list.d/memsql.list -
Install the SingleStore client.
sudo apt update && sudo apt -y install singlestore-client
Offline Installation
For clusters that must be deployed in an environment without Internet access, download the SingleStore client package onto a host that can access the main deployment host.
Copy the SingleStore client package onto the target host (typically the main deployment host when deploying SingleStoreDB) and install the SingleStore client.
sudo dpkg -i /tmp/singlestore-client_<version>_<commit-hash>_amd64.deb
Tarball
Download the SingleStore Client
Download the SingleStore client tarball file onto a host that can access the main deployment host.
Transfer the SingleStore Client
Transfer the SingleStore client tarball file into a dedicated singlestore
directory on the target host (typically the main deployment host when deploying SingleStoreDB) that has been configured so that non-sudo
users can access it, such as /home/<user>/singlestore
or /opt/singlestore
.
Unpack the SingleStore Client
Unpack the SingleStore client tarball file into the singlestore
directory.
tar xzvf singlestore-client-<version>-<commit-hash>.x86_64.tar.gz
Using symbolic links (or "symlinks") can make using and upgrading the SingleStore client easier.singlestore
command to be run from anywhere on the filesystem, even after an upgrade by updating the symlink.
-
Navigate to the directory that contains the unpacked SingleStore client tarball file and create a
singlestore-client
symlink that points to the SingleStore client directory.ln -s singlestore-client-<version>-<commit-hash> singlestore-client -
Verify that the symlink has been created.
ls -lsinglestore-client -> singlestore-client-1.0.6-c3803db03b
-
Update the
PATH
environment variable with the path to the newsinglestore-client
directory.This path can also be added to your shell startup file so you won't have to run this command each time you log in. export PATH=/home/<user>/singlestore/singlestore-client:$PATH -
You may now run the
singlestore
command from anywhere on the filesystem.singlestore
Once the SingleStore client has been installed:
-
Obtain a ticket from the Kerberos server.
kinit <username>@<hostname>Password for <username>@<hostnae>:
-
Connect with the SingleStore client.
-
For a package-based installation of the SingleStore client.
singlestore -h<hostname> --plugin-dir=/usr/lib/singlestore-client/plugin/ -u<username> -
For a tarball-based installation of the SingleStore client.
singlestore -h<hostname> --plugin-dir=/path/to/singlestore-client/plugin/ -u<username>
-
Option 2: Use the MariaDB Client
-
Obtain a ticket from the Kerberos server.
kinit <username>@<hostname>Password for <username>@<hostname>:
-
Connect with the MariaDB client.
mysql --plugin-dir=/path/to/plugin-dir -u <username> --prompt="singlestore> "
Note that this authentication method requires you to specify the plugin directory that contains the auth_
plugin for MariaDB, as described in Assumptions and Prerequisites.
To connect using ODBC, consider the following example:
Driver=<path-to-mariadb-odbc-connector>;Database=information_schema;ServerName=10.0.0.1;Port=3306;UID=myusername;Plugin_Dir=<path-to-gssapi-plugin-directory>;
Last modified: April 26, 2023