Description\n-----------\n\nThe gssapi authentication plugin allows the user to authenticate with services that use the Generic Security Services Application Program Interface (GSSAPI). Windows has a slightly different but very similar API called Security Support Provider Interface (SSPI). The GSSAPI is a standardized API described in RFC2743 and RFC2744. The client and server negotiate using a standardized protocol described in RFC7546.\n\nOn Windows, this authentication plugin supports Kerberos and NTLM authentication. Windows authentication is supported regardless of whether a domain is used in the environment.\n\nOn Unix systems, the most dominant GSSAPI service is Kerberos). However, it is less commonly used on Unix systems than it is on Windows. Regardless, this authentication plugin also supports Kerberos authentication on Unix.\n\nThe gssapi authentication plugin is most often used for authenticating with Microsoft Active Directory.\n\nThis article gives instructions on configuring the gssapi authentication plugin\\\nfor MariaDB for passwordless login.\n\nInstalling the Plugin's Package\n\nSince MariaDB 10.11, on Windows, the plugin is included in the server. There is no need for separate installation.\n\nThe gssapi authentication plugin's shared library is included in MariaDB packages as the auth_gssapi.so or auth_gssapi.dll shared library on systems where it can be built.\n\nInstalling on Linux\n\nThe gssapi authentication plugin is included in binary tarballs on Linux.\n\nInstalling with a Package Manager\n\nThe gssapi authentication plugin can also be installed via a package manager on Linux. In order to do so, your system needs to be configured to install from one of the MariaDB repositories.\n\nYou can configure your package manager to install it from MariaDB Corporation's MariaDB Package Repository by using the MariaDB Package Repository setup script.\n\nYou can also configure your package manager to install it from MariaDB Foundation's MariaDB Repository by using the MariaDB Repository Configuration Tool.\n\nInstalling with yum/dnf\n\nOn RHEL, CentOS, Fedora, and other similar Linux distributions, it is highly recommended to install the relevant RPM package from MariaDB's repository using yum or dnf). Starting with RHEL 8 and Fedora 22, yum has been replaced by dnf, which is the next major version of yum. However, yum commands still work on many systems that use dnf:\n\n``bash\nsudo yum install MariaDB-gssapi-server\n`\n\nInstalling with apt-get\n\nOn Debian, Ubuntu, and other similar Linux distributions, it is highly recommended to install the relevant DEB package from MariaDB's repository using apt-get:\n\n`bash\nsudo apt-get install mariadb-plugin-gssapi-server\n`\n\nInstalling with zypper\n\nOn SLES, OpenSUSE, and other similar Linux distributions, it is highly recommended to install the relevant RPM package from MariaDB's repository using zypper:\n\n`bash\nsudo zypper install MariaDB-gssapi-server\n`\n\nInstalling on Windows\n\nBefore MariaDB 10.11, the gssapi authentication plugin is included in MSI and ZIP packages on Windows.\n\nInstalling the Plugin\n\nSince MariaDB 10.11, on Windows, the plugin is included in the server. There is no need for separate installation.\n\nOn Windows, and on other operating systems, although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.\n\nThe first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN:\n\n`sql\nINSTALL SONAME 'auth_gssapi';\n`\n\nThe second method can be used to tell the server to load the plugin when it starts up. The plugin can be installed this way by providing the --plugin-load or the --plugin-load-add options. This can be specified as a command-line argument to mariadbd or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\nplugin_load_add = auth_gssapi\n`\n\nUninstalling the Plugin\n\nYou can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN:\n\n`sql\nUNINSTALL SONAME 'auth_gssapi';\n`\n\nIf you installed the plugin by providing the --plugin-load or the --plugin-load-add options in a relevant server option group in an option file, then those options must be removed to prevent the plugin from being loaded the next time the server is restarted.\n\nConfiguring the Plugin\n\nIf the MariaDB server is running on Unix, then some additional configuration steps will need to be implemented in order to use the plugin.\n\nIf the MariaDB server is running on Windows, then no special configuration steps will need to be implemented in order to use the plugin, as long as the following is true:\n\n The Windows server is joined to a domain.\n The MariaDB server process is running as either a NetworkService Account or a Domain User Account.\n\nCreating a Keytab File on Unix\n\nIf the MariaDB server is running on Unix, then the KDC server will need to create a keytab file for the MariaDB server. The keytab file contains the service principal name, which is the identity that the MariaDB server will use to communicate with the KDC server. The keytab will need to be transferred to the MariaDB server, and the mysqld server process will need read access to this keytab file.\n\nHow this keytab file is generated depends on whether the KDC server is Microsoft Active Directory KDC or MIT Kerberos KDC.\n\nCreating a Keytab File with Microsoft Active Directory\n\nIf you are using Microsoft Active Directory KDC, you may need to create a keytab using the ktpass.exe utility on a Windows host. The service principal will need to be mapped to an existing domain user. To do so, follow the steps listed below.\n\nBe sure to replace the following items in the step below:\n\n Replace ${HOST} with the fully qualified DNS name for the MariaDB server host.\n Replace ${DOMAIN} with the Active Directory domain.\n Replace ${AD_USER} with the existing domain user.\n Replace ${PASSWORD} with the password for the service principal.\n\nTo create the service principal, execute the following command:\n\n`bash\nktpass.exe /princ mariadb/${HOST}@${DOMAIN} /mapuser ${AD_USER} /pass ${PASSWORD} /out mariadb.keytab /crypto all /ptype KRB5_NT_PRINCIPAL /mapop set\n`\n\nCreating a Keytab File with MIT Kerberos\n\nIf you are using MIT Kerberos KDC, then you can create a keytab file using the kadmin utility. To do so, follow the steps listed below.\n\nIn the following steps, be sure to replace ${HOST} with the fully qualified DNS name for the MariaDB server host.\n\nFirst, create the service principal using the kadmin utility:\n\n`bash\nkadmin -q "addprinc -randkey mariadb/${HOST}"\n`\n\nThen, export the newly created user to the keytab file using the kadmin utility:\n\n`bash\nkadmin -q "ktadd -k /path/to/mariadb.keytab mariadb/${HOST}"\n`\n\nMore details can be found at the following links:\n\n MIT Kerberos Documentation: Database administration\n MIT Kerberos Documentation: Application servers\n\nConfiguring the Path to the Keytab File on Unix\n\nIf the MariaDB server is running on Unix, then the path to the keytab file that was previously created can be set by configuring the gssapi_keytab_path system variable. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\ngssapi_keytab_path=/path/to/mariadb.keytab\n`\n\nConfiguring the Service Principal Name\n\nThe service principal name can be set by configuring the gssapi_principal_name system variable. This can be specified as a command-line argument to mariadbd, or it can be specified in a relevant server option group in an option file:\n\n`ini\n[mariadb]\n...\ngssapi_principal_name=service_principal_name/host.domain.com@REALM\n`\n\nIf a service principal name is not provided, the plugin tries to use mariadb/host.domain.com@REALM by default.\n\nIf the MariaDB server is running on Unix, the plugin needs a service principal name in order to function.\n\nIf the MariaDB server is running on Windows, the plugin does not usually need a service principal in order to function. However, if you want to use one, anyway, it can be created with the setspn utility.\n\nDifferent KDC implementations may use different canonical forms to identify principals. See RFC2744: Section 3.10 to learn what the standard says about principal names.\n\nMore details can be found at the following links:\n\n Active Directory Domain Services: Service Principal Names\n MIT Kerberos Documentation: Realm configuration decisions\n MIT Kerberos Documentation: Principal names and DNS\n\nCreating Users\n\nTo create a user account via CREATE USER, specify the name of the plugin in the IDENTIFIED VIA clause:\n\n`sql\nCREATE USER username@hostname IDENTIFIED VIA gssapi;\n`\n\nIf SQL_MODE does not have NO_AUTO_CREATE_USER set, then you can also create the user account via GRANT:\n\n`sql\nGRANT SELECT ON db. TO username@hostname IDENTIFIED VIA gssapi;\n`\n\nYou can also specify the user's realm for MariaDB with the USING clause:\n\n`sql\nCREATE USER username@hostname IDENTIFIED VIA gssapi USING 'username@EXAMPLE.COM';\n`\n\nThe format of the realm depends on the specific authentication mechanism that is used. For example, the format would need to be machine\\\\username for Windows users authenticating with NTLM.\n\nIf the realm is not provided in the user account's definition, then the realm is not used for comparison. Therefore, 'usr1@EXAMPLE.COM', 'usr1@EXAMPLE.CO.UK' and 'mymachine\\usr1' would all identify as the following user account:\n\n`sql\nCREATE USER usr1@hostname IDENTIFIED VIA gssapi;\n`\n\nCreating Users Identified Via Group Membership or SID (Windows-specific)\n\nOn Windows only, it is possible to login using a AD or local group-membership. This is achieved by using the GROUP prefix in IDENTIFIED ... AS:\n\n`sql\nCREATE USER root IDENTIFIED VIA gssapi AS 'GROUP:Administrators'\nCREATE USER root IDENTIFIED VIA gssapi AS 'GROUP:BUILTIN\\\\Administrators'\n`\n\nThe effect of the above definition is that every user that identifies as a member of group Administrators can log in using the user name root without a password.\n\nUser can also login using own or group SID (Security Identifier):\n\n`sql\nCREATE USER root IDENTIFIED VIA gssapi AS 'SID:S-1-5-32-544'\n`\n\nUsing SIDs will perform slightly faster than using name (since it will spare translation between SID and name which is otherwise done). SIDs are immune against user or group renaming.\n\nPasswordless login on Windows\n\nThis feature is available from MariaDB 10.11.\n\nOn Windows, in addition to the usual authentication with a password, passwordless authentication is permitted when creating the root user during installation. This works in a similar manner to Unix socket authentication. However, since auth_gssapi, unlike unix_socket, requires client support, to avoid failures when MariaDB is used with third-party drivers, authentication on Windows first attempts password-based native_authentication, and only if it fails, falls back to passwordless auth_gssapi.\n\nClient Authentication Plugins\n\nFor clients that use the libmysqlclient or MariaDB Connector/C libraries, MariaDB provides one client authentication plugin that is compatible with the gssapi authentication plugin:\n\n auth_gssapi_client\n\nWhen connecting with a client or utility to a server as a user account that authenticates with the gssapi authentication plugin, you may need to tell the client where to find the relevant client authentication plugin by specifying the --plugin-dir option:\n\n`bash\nmysql --plugin-dir=/usr/local/mysql/lib64/mysql/plugin --user=alice\n`\n\nauth_gssapi_client\n\nThe auth_gssapi_client client authentication plugin receives the principal name from the server, and then uses either the gss_init_sec_context function (on Unix) or the InitializeSecurityContext function (on Windows) to establish a security context on the client.\n\nSupport in Client Libraries\n\nUsing the Plugin with MariaDB Connector/C\n\nMariaDB Connector/C supports gssapi authentication using the client authentication plugins mentioned in the previous section.\n\nUsing the Plugin with MariaDB Connector/ODBC\n\nMariaDB Connector/ODBC supports gssapi authentication using the client authentication plugins mentioned in the previous section.\n\nUsing the Plugin with MariaDB Connector/J\n\nMariaDB Connector/J supports gssapi authentication. Current documentation can be found here.\n\nUsing the Plugin with MariaDB Connector/Node.js\n\nMariaDB Connector/Node.js does not yet support gssapi authentication. See CONJS-72 for more information.\n\nUsing the Plugin with MySqlConnector for .NET\n\nMySqlConnector for ADO.NET supports gssapi authentication.\n\nThe support is transparent. Normally, the connector only needs to be provided the correct user name, and no other parameters are required.\n\nHowever, this connector also supports the ServerSPN connection string parameter, which can be used for mutual authentication.\n\n.NET specific problems/workarounds\n\nWhen connecting from Unix client to Windows server with ADO.NET, in an Active Directory domain environment, be aware that .NET Core on Unix does not support principal names in UPN(User Principal Name) form, which is default on Windows (e.g machine$@domain.com) . Thus, upon encountering an authentication exception with "server not found in Kerberos database", use one of workarounds below\n\n Force host-based SPN on server side.\n   For example, this can be done by setting the gssapi_principal_name system variable to HOST/machine in a server option group in an option file.\n Pass host-based SPN on client side.\n   For example, this can be done by setting the connector's ServerSPN connection string parameter to HOST/machine.\n\nSystem Variables\n\ngssapi_keytab_path\n\n Description: Defines the path to the server's keytab file.\n   This system variable is only meaningful on Unix.\n   See Creating a Keytab File on Unix and Configuring the Path to the Keytab File on Unix for more information.\n Command line: --gssapi-keytab-path\n Scope: Global\n Dynamic: No\n Data Type: string\n Default Value: ''\n Introduced: MariaDB 10.1.11\n\ngssapi_principal_name\n\n Description: Name of the service principal.\n   See Configuring the Service Principal Name for more information.\n Command line: --gssapi-principal-name\n Scope: Global\n Dynamic: No\n Data Type: string\n Default Value: ''\n Introduced: MariaDB 10.1.11\n\ngssapi_mech_name\n\n Description: Name of the SSPI package used by server. Can be either 'Kerberos' or 'Negotiate'. Set it to 'Kerberos', to prevent less secure NTLM in domain environments, but leave it as default (Negotiate) to allow non-domain environments (e.g if server does not run in a domain environment).\n   This system variable is only meaningful on Windows.\n Command line: --gssapi-mech-name\n Scope: Global\n Dynamic: No\n Data Type: enumerated\n Default Value: Negotiate\n Valid Values: Kerberos, Negotiate\n Introduced: MariaDB 10.1.11\n\nOptions\n\ngssapi\n\n Description: Controls how the server should trea\n\n[Truncated — full content at mariadb.com/docs]