.. _quick_start_krb: |guide| Quick Start KRB ================================================== This section contains a Quick Start |guide| for the Secure PVAccess *Kerberos Authenticator*. The Kerberos Authenticator is an Authenticator that uses a kerberos ticket to create an X.509 certificate. It takes the ``PRINCIPAL`` from the ticket and splits it up on '@' to extract the ``common name``, and ``organization`` for the certificate's subject while leaving the ``organizational unit`` blank. The information is sent to the PVACMS which validates that the request is authentic and the credentials correct by contacting the KDC. If all checks-out then certificates are generated in the ``VALID`` state. Our starting point for this Quick Start Guide is the end of the :ref:`quick_start_std` so if you haven't gone through it yet do that now then come back here. You need to have users's configured (``pvacms``, ``admin``, ``softioc``, and ``client``). We will set up a containerised KDC and configure it so that the users can get tickets. We will create a pvacms Kerberos service and provide PVACMS a keytab for passwordless authentication so that it can verify CCRs presented by clients requesting new certificates. See :ref:`secure_pvaccess` for general documentation on Secure PVAccess. Other Quick Start Guides: - :ref:`quick_start` - :ref:`quick_start_std` - :ref:`quick_start_ldap` |learn| You will learn: ****************************** - :ref:`Creating a containerised KDC `, - :ref:`Building PVXS with Kerberos Authenticator support `, - :ref:`Exporting pvacms keytab from KDC and configuring pvacms to use it `, - :ref:`Creating certificates using the Kerberos Authenticator` and - :ref:`Connecting a Kerberos Client to an SPVA Server` |pre-packaged|\Prepackaged ****************************** If you want a prepackaged environment, try the following. You will need three terminal sessions. |1| Load image ------------------------------ - |terminal|\¹ - start new container with Prepackaged Secure PVAccess with Kerberos Authenticator and 4 Users .. code-block:: shell docker run -it --name spva_krb georgeleveln/spva_krb:latest .. code-block:: console 2025-03-08 14:40:43,319 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message. 2025-03-08 14:40:43,319 INFO Included extra file "/etc/supervisor/conf.d/kadmind.conf" during parsing 2025-03-08 14:40:43,319 INFO Included extra file "/etc/supervisor/conf.d/krb5kdc.conf" during parsing 2025-03-08 14:40:43,319 INFO Included extra file "/etc/supervisor/conf.d/pvacms.conf" during parsing 2025-03-08 14:40:43,322 INFO supervisord started with pid 1 2025-03-08 14:40:44,334 INFO spawned: 'krb5-admin-server' with pid 7 2025-03-08 14:40:44,338 INFO spawned: 'krb5-kdc' with pid 8 2025-03-08 14:40:44,346 INFO spawned: 'pvacms' with pid 9 2025-03-08 14:40:45,589 INFO success: krb5-admin-server entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2025-03-08 14:40:45,589 INFO success: krb5-kdc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2025-03-08 14:40:45,589 INFO success: pvacms entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) |2| Service ------------------------------ - |terminal|\² - log in as softioc service account .. code-block:: shell docker exec -it --user softioc spva_krb /bin/bash - get a kerberos ticket. Enter "secret" as the password when prompted .. code-block:: shell kinit .. code-block:: console Password for softioc@EPICS.ORG: .. code-block:: shell klist .. code-block:: console Ticket cache: FILE:/tmp/krb5cc_1003 Default principal: softioc@EPICS.ORG Valid starting Expires Service principal 03/08/25 15:23:09 03/09/25 15:23:09 krbtgt/EPICS.ORG@EPICS.ORG renew until 03/08/25 15:23:09 03/08/25 15:23:21 03/09/25 15:23:09 pvacms/cluster@EPICS.ORG renew until 03/08/25 15:23:09 - create a server certificate using the Kerberos Authenticator .. code-block:: shell authnkrb -u server .. code-block:: console Keychain file created : /home/softioc/.config/pva/1.3/server.p12 Certificate identifier : 47530d89:3826361579604613181 .. code-block:: shell pvxcert -f ~/.config/pva/1.3/server.p12 .. code-block:: console Certificate Details: ============================================ Certificate ID : 47530d89:3826361579604613181 Entity Subject : CN=softioc, O=EPICS.ORG Issuer Subject : CN=EPICS Root Certificate Authority, C=US, O=certs.epics.org, OU=EPICS Certificate Authority Valid From : Sat Mar 08 15:23:21 2025 UTC Expires On : Sun Mar 09 15:23:09 2025 UTC -------------------------------------------- Certificate Status: ============================================ Certificate ID: 47530d89:3826361579604613181 Status : VALID Status Issued : Sat Mar 08 15:47:14 2025 UTC Status Expires: Sat Mar 08 16:17:14 2025 UTC -------------------------------------------- |3| Client ------------------------------ - |terminal|\³ - log in as a Secure PVAccess client .. code-block:: shell docker exec -it --user client spva_krb /bin/bash - get a kerberos ticket. Enter "secret" as the password when prompted .. code-block:: shell kinit .. code-block:: console Password for client@EPICS.ORG: .. code-block:: shell klist .. code-block:: console Ticket cache: FILE:/tmp/krb5cc_1004 Default principal: client@EPICS.ORG Valid starting Expires Service principal 03/08/25 15:27:50 03/09/25 15:27:50 krbtgt/EPICS.ORG@EPICS.ORG renew until 03/08/25 15:27:50 - create a client certificate using the Kerberos Authenticator .. code-block:: shell authnkrb .. code-block:: console Keychain file created : /home/client/.config/pva/1.3/client.p12 Certificate identifier : 47530d89:15177030356392297708 .. code-block:: shell pvxcert -f ~/.config/pva/1.3/client.p12 .. code-block:: console Certificate Details: ============================================ Certificate ID : 47530d89:15177030356392297708 Entity Subject : CN=client, O=EPICS.ORG Issuer Subject : CN=EPICS Root Certificate Authority, C=US, O=certs.epics.org, OU=EPICS Certificate Authority Valid From : Sat Mar 08 15:31:44 2025 UTC Expires On : Sun Mar 09 15:27:50 2025 UTC -------------------------------------------- Certificate Status: ============================================ Certificate ID: 47530d89:15177030356392297708 Status : VALID Status Issued : Sat Mar 08 15:40:20 2025 UTC Status Expires: Sat Mar 08 16:10:20 2025 UTC -------------------------------------------- |4| Start SoftIOC ------------------------------ - |terminal|\² - start SoftIOC .. code-block:: shell softIocPVX \ -m user=test,N=tst,P=tst \ -d ${PROJECT_HOME}/pvxs/test/testioc.db \ -d ${PROJECT_HOME}/pvxs/test/testiocg.db \ -d ${PROJECT_HOME}/pvxs/test/image.db \ -G ${PROJECT_HOME}/pvxs/test/image.json \ -a ${PROJECT_HOME}/pvxs/test/testioc.acf .. code-block:: console INFO: PVXS QSRV2 is loaded, permitted, and ENABLED. 2025-03-08T15:36:11.265341125 WARN pvxs.tcp.init Server unable to bind TCP port 5075, falling back to [::]:39377 2025-03-08T15:36:11.265436375 WARN pvxs.tcp.init Server unable to bind TLS port 5076, falling back to [::]:34381 Starting iocInit ############################################################################ ## EPICS R7.0.8.2-DEV ## Rev. R7.0.8.1-123-g48607a42586b1a316cd6 ## Rev. Date Git: 2024-11-29 17:08:28 +0000 ############################################################################ iocRun: All initialization complete epics> |5| Get PV value ------------------------------ - |terminal|\³ - get a PV ``test:enumExample`` value from the SoftIOC .. code-block:: shell pvxinfo -v test:enumExample .. code-block:: console Effective config EPICS_PVA_AUTO_ADDR_LIST=YES EPICS_PVA_BROADCAST_PORT=5076 EPICS_PVA_CONN_TMO=30 EPICS_PVA_SERVER_PORT=5075 EPICS_PVA_TLS_KEYCHAIN=/home/client/.config/pva/1.3/client.p12 EPICS_PVA_TLS_OPTIONS=on_expiration=fallback-to-tcp on_no_cms=fallback-to-tcp EPICS_PVA_TLS_PORT=5076 XDG_CONFIG_HOME=/home/client/.config/pva/1.3 XDG_DATA_HOME=/home/client/.local/share/pva/1.3 # TLS x509:47530d89:3826361579604613181:EPICS Root Certificate Authority/softioc@172.17.0.2:34381 test:enumExample from 172.17.0.2:34381 struct "epics:nt/NTEnum:1.0" { struct "enum_t" { int32_t index string[] choices } value struct "alarm_t" { int32_t severity int32_t status string message } alarm struct "time_t" { int64_t secondsPastEpoch int32_t nanoseconds int32_t userTag } timeStamp struct { string description } display } - verify that connection is TLS - ``TLS x509:47530d89:3826361579604613181:EPICS Root Certificate Authority/softioc @ 172.17.0.2`` indicates that: - The connection is ``TLS``, - The Server end of the channel has been authenticated by the Root Certificate Authority ``EPICS Root Certificate Authority`` - The Server end of the channel's name has been authenticated as ``softioc`` and is connecting from host ``172.17.0.2`` |step-by-step| Step-By-Step ******************************** +----------------------+---------------------+--------------------------+----------------------+--------------------------------------+-----------------------------------------------------------------------+ | Env. *authnkrb* | Env. *pvacms* | Params. *authkrb* | Params. *pvacms* | Keys and Values | Description | +======================+=====================+==========================+======================+======================================+=======================================================================+ || || KRB5_KTNAME || || ``--krb-keytab`` || {string location of keytab file} || This is the keytab file shared with :ref:`pvacms` by the KDC so | || || || || || e.g. ``/etc/security/keytab`` || that it can verify kerberos tickets | || +---------------------+| || || || | || || KRB5_CLIENT_KTNAME || || || || | || || || || || || | +----------------------+---------------------+--------------------------+----------------------+--------------------------------------+-----------------------------------------------------------------------+ || EPICS_AUTH_KRB_VALIDATOR_SERVICE || ``--krb-validator`` || {this is validator service name} || The name of the service user created in the KDC that the pvacms | || || || e.g. ``pvacms`` || service will log in as. `/cluster@{realm}` will be added | +--------------------------------------------+-------------------------------------------------+--------------------------------------+-----------------------------------------------------------------------+ || EPICS_AUTH_KRB_REALM || ``--krb-realm`` || e.g. ``EPICS.ORG`` || Kerberos REALM to authenticate against | +--------------------------------------------+-------------------------------------------------+--------------------------------------+-----------------------------------------------------------------------+ |step| Docker Image ------------------------------------------ |1| Use a Prepackaged spva_std image ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - |terminal|\¹ - open a terminal and load pre-built image - don't forget to add /bin/bash at the end to suppress running the pvacms .. code-block:: shell docker run -it --name spva_krb georgeleveln/spva_std:latest /bin/bash .. _spva_qs_krb_kdc: |step| KDC & KAdmin ------------------------------------------ This section shows how to install and configure a Kerberos KDC and kadmin. This is included to enable you to test the Kerberos Authenticator before deploying it into your network. It will enable you to configure EPICS agents that have valid kerberos tickets that can be exchanged for X.509 certificates using the Kerberos Authenticator. |1| Install prerequisites ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Add kerberos dependencies - krb5 admin server (kadmin) - krb5 KDC - libkrb5 development library for compiling pvxs with Kerberos Authenticator support .. code-block:: shell apt-get update && \ apt-get -y install \ --no-install-recommends \ krb5-admin-server \ krb5-kdc \ libkrb5-dev .. code-block:: console Hit:1 http://ports.ubuntu.com/ubuntu-ports noble InRelease Get:2 http://ports.ubuntu.com/ubuntu-ports noble-updates InRelease [126 kB] Get:3 http://ports.ubuntu.com/ubuntu-ports noble-backports InRelease [126 kB] Get:4 http://ports.ubuntu.com/ubuntu-ports noble-security InRelease [126 kB] ... invoke-rc.d: policy-rc.d denied execution of start. Setting up krb5-admin-server (1.20.1-6ubuntu2.5) ... invoke-rc.d: could not determine current runlevel invoke-rc.d: policy-rc.d denied execution of start. Processing triggers for libc-bin (2.39-0ubuntu8.4) ... .. _spva_qs_krb_build: |2| Rebuild pvxs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - enable Kerberos Authenticator by updating ``CONFIG_SITE.local`` - do a clean rebuild of pvxs .. code-block:: shell export PROJECT_HOME=/opt/epics cd ${PROJECT_HOME} cat >> CONFIG_SITE.local < /etc/krb5kdc/kdc.conf < /etc/krb5kdc/kadm5.acl < /etc/krb5kdc/badpass.txt < /etc/krb5.conf <> /home/pvacms/.bashrc < /etc/supervisor/conf.d/kadmind.conf < /etc/supervisor/conf.d/krb5kdc.conf <> /etc/supervisor/conf.d/pvacms.conf < than 1 seconds (startsecs) 2025-03-10 02:31:40,825 INFO success: krb5-kdc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2025-03-10 02:31:40,825 INFO success: pvacms entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) .. _spva_qs_krb_server: |step| Run SoftIOC ------------------------------------------ |1| Login as softioc in a new shell ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - |terminal|\² .. code-block:: shell docker exec -it --user softioc spva_krb /bin/bash |3| kerberos login ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - do a kerberos login to get a kerberos ticket. Enter "secret" as the password when prompted .. code-block:: shell kinit .. code-block:: console Password for softioc@EPICS.ORG: .. code-block:: shell klist .. code-block:: console Ticket cache: FILE:/tmp/krb5cc_1003 Default principal: softioc@EPICS.ORG Valid starting Expires Service principal 03/10/25 03:16:25 03/11/25 03:16:25 krbtgt/EPICS.ORG@EPICS.ORG renew until 03/10/25 03:16:25 |3| Get Certificate ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - create a softioc server certificate - creates softioc server certificate - at location specified by ``EPICS_PVAS_TLS_KEYCHAIN`` or ``${XDG_CONFIG_HOME}/pva/1.3/server.p12`` by default .. code-block:: shell authnkrb -u server .. code-block:: console Keychain file created : /home/softioc/.config/pva/1.3/server.p12 Certificate identifier : b271f07a:12421554925305118824 |4| Check the certificate status is VALID ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - check that the generated certificate is ``VALID`` - note that the *name* is ``softioc`` - picked up from ``principal`` in kerberos ticket - note that the *organization* is ``EPICS.ORG`` - picked up from ``REALM`` in kerberos ticket - note that the *expiration date* is the same as the expiration of the kerberos ticket - note that the *start date* is set to the date of certificate issuance .. code-block:: shell pvxcert -f ~/.config/pva/1.3/server.p12 .. code-block:: console Certificate Details: ============================================ Certificate ID : b271f07a:12421554925305118824 Entity Subject : CN=softioc, O=EPICS.ORG Issuer Subject : CN=EPICS Root Certificate Authority, C=US, O=certs.epics.org, OU=EPICS Certificate Authority Valid From : Mon Mar 10 03:20:05 2025 UTC Expires On : Tue Mar 11 03:16:25 2025 UTC -------------------------------------------- Certificate Status: ============================================ Certificate ID: b271f07a:12421554925305118824 Status : VALID Status Issued : Mon Mar 10 03:22:14 2025 UTC Status Expires: Mon Mar 10 03:52:14 2025 UTC -------------------------------------------- |5| Run Secure PVAccess Service ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - start the service .. code-block:: shell softIocPVX \ -m user=test,N=tst,P=tst \ -d ${PROJECT_HOME}/pvxs/test/testioc.db \ -d ${PROJECT_HOME}/pvxs/test/testiocg.db \ -d ${PROJECT_HOME}/pvxs/test/image.db \ -G ${PROJECT_HOME}/pvxs/test/image.json \ -a ${PROJECT_HOME}/pvxs/test/testioc.acf .. code-block:: console INFO: PVXS QSRV2 is loaded, permitted, and ENABLED. 2025-03-10T03:28:17.264206926 WARN pvxs.tcp.init Server unable to bind TCP port 5075, falling back to [::]:46831 2025-03-10T03:28:17.264284426 WARN pvxs.tcp.init Server unable to bind TLS port 5076, falling back to [::]:37027 Starting iocInit ############################################################################ ## EPICS R7.0.8.2-DEV ## Rev. R7.0.8.1-123-g48607a42586b1a316cd6 ## Rev. Date Git: 2024-11-29 17:08:28 +0000 ############################################################################ iocRun: All initialization complete epics> .. _spva_qs_krb_client: |step| SPVA Client ------------------------------------------ |1| Login as client in a new shell ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - |terminal|\³ .. code-block:: shell docker exec -it --user client spva_krb /bin/bash |2| kerberos login ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - do a kerberos login to get a kerberos ticket. Enter "secret" as the password when prompted .. code-block:: shell kinit .. code-block:: console Password for client@EPICS.ORG: .. code-block:: shell klist .. code-block:: console Ticket cache: FILE:/tmp/krb5cc_1004 Default principal: client@EPICS.ORG Valid starting Expires Service principal 03/10/25 03:30:32 03/11/25 03:30:32 krbtgt/EPICS.ORG@EPICS.ORG renew until 03/10/25 03:30:32 |3| Get Certificate ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - create a client certificate - creates a client certificate - at location specified by ``EPICS_PVA_TLS_KEYCHAIN`` or ``${XDG_CONFIG_HOME}/pva/1.3/client.p12`` by default .. code-block:: shell authnkrb .. code-block:: console Keychain file created : /home/client/.config/pva/1.3/client.p12 Certificate identifier : b271f07a:1204731550645534180 |4| Check the certificate status is VALID ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - check that the generated certificate is ``VALID`` - note that the *name* is ``client`` - picked up from ``principal`` in kerberos ticket - note that the *organization* is ``EPICS.ORG`` - picked up from ``REALM`` in kerberos ticket - note that the *expiration date* is the same as the expiration of the kerberos ticket - note that the *start date* is set to the date of certificate issuance .. code-block:: shell pvxcert -f ~/.config/pva/1.3/client.p12 .. code-block:: console Certificate Details: ============================================ Certificate ID : b271f07a:1204731550645534180 Entity Subject : CN=client, O=EPICS.ORG Issuer Subject : CN=EPICS Root Certificate Authority, C=US, O=certs.epics.org, OU=EPICS Certificate Authority Valid From : Mon Mar 10 03:32:57 2025 UTC Expires On : Tue Mar 11 03:30:32 2025 UTC -------------------------------------------- Certificate Status: ============================================ Certificate ID: b271f07a:1204731550645534180 Status : VALID Status Issued : Mon Mar 10 03:33:58 2025 UTC Status Expires: Mon Mar 10 04:03:58 2025 UTC -------------------------------------------- |5| Test TLS client operations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: shell pvxget -F tree test:structExample .. code-block:: console test:structExample ... - show that TLS is being used .. code-block:: shell pvxinfo -v test:enumExample .. code-block:: console Effective config EPICS_PVA_AUTO_ADDR_LIST=YES EPICS_PVA_BROADCAST_PORT=5076 EPICS_PVA_CONN_TMO=30 EPICS_PVA_SERVER_PORT=5075 EPICS_PVA_TLS_KEYCHAIN=/home/client/.config/pva/1.3/client.p12 EPICS_PVA_TLS_OPTIONS=on_expiration=fallback-to-tcp on_no_cms=fallback-to-tcp EPICS_PVA_TLS_PORT=5076 XDG_CONFIG_HOME=/home/client/.config/pva/1.3 XDG_DATA_HOME=/home/client/.local/share/pva/1.3 # TLS x509:b271f07a:12421554925305118824:EPICS Root Certificate Authority/softioc@172.17.0.2:37027 test:enumExample from 172.17.0.2:37027 struct "epics:nt/NTEnum:1.0" { struct "enum_t" { int32_t index string[] choices } value struct "alarm_t" { int32_t severity int32_t status string message } alarm struct "time_t" { int64_t secondsPastEpoch int32_t nanoseconds int32_t userTag } timeStamp struct { string description } display } .. note:: - ``TLS x509:b271f07a:12421554925305118824:EPICS Root Certificate Authority/softioc @ 172.17.0.2`` indicates that: - The connection is ``TLS``, - The Server end of the channel has been authenticated by the Root Certificate Authority ``EPICS Root Certificate Authority`` - The Server end of the channel's name has been authenticated as ``softioc`` and is connecting from host ``172.17.0.2``