Difference between revisions of "Kerberos"

From ArchWiki
Jump to navigation Jump to search
m (→‎Domain creation: Set +preauth)
(Fix client keytab generation. root/admin unnecessary. Reorganize/deduplicate.)
Line 24: Line 24:
  
 
[realms]
 
[realms]
# use "kdc = ..." if the kerberos SRV records aren't in DNS (see Advanced section)
 
 
     EXAMPLE.COM = {
 
     EXAMPLE.COM = {
 
         admin_server = kerberos.example.com
 
         admin_server = kerberos.example.com
 +
        # use "kdc = ..." if the kerberos SRV records aren't in DNS (see Advanced section)
 
         kdc = kerberos.example.com
 
         kdc = kerberos.example.com
 +
        # This breaks krb4 compatibility but increases security
 
         default_principal_flags = +preauth
 
         default_principal_flags = +preauth
 
     }
 
     }
Line 61: Line 62:
 
{{hc|# kadmin.local|Authenticating as principal root/admin@EXAMPLE.COM with password.
 
{{hc|# kadmin.local|Authenticating as principal root/admin@EXAMPLE.COM with password.
 
kadmin.local:}}
 
kadmin.local:}}
 
Add the admin user principal to the Kerberos database:
 
{{hc|kadmin.local: addprinc root/admin|<nowiki>
 
WARNING: no policy specified for root/admin@EXAMPLE.COM; defaulting to no policy
 
Enter password for principal "root/admin@EXAMPLE.COM": ***
 
Re-enter password for principal "root/admin@EXAMPLE.COM": ***
 
Principal "root/admin@EXAMPLE.COM" created.
 
</nowiki>}}
 
  
 
Add a user principal to the Kerberos database:
 
Add a user principal to the Kerberos database:
Line 102: Line 95:
 
</nowiki>}}
 
</nowiki>}}
  
== Client configuration ==
+
=== Firewall ===
=== Join the domain ===
+
Add ALLOW rules to your firewall for any applicable ports/protocols:
Edit {{ic|/etc/krb5.conf}} to match your server's configuration.  You can simply copy this file from the server.
+
* 88, TCP and UDP for Kerberos v5
 +
* 749, TCP and UDP for kadmin if you plan to configure it
 +
* 750, TCP and UDP for Kerberos v4 if you need backwards compatibility
  
=== Create client principals ===
+
=== DNS records ===
Start the Kerberos administration tool on the Kerberos server:
+
This isn't necessary if you specify the kerberos and kadmin server in each machine's krb5.conf
{{hc|# kadmin.local|<nowiki>
+
{{hc|db.example.com|
Authenticating as principal root/admin@EXAMPLE.COM with password.
+
kerberos.example.com.          A    1.2.3.4
</nowiki>}}
+
_kerberos.example.com.          TXT  "EXAMPLE.COM"
 +
_kerberos._udp.example.com.    SRV  0 0  88 kerberos.example.com.
 +
_kerberos-adm._udp.example.com. SRV  0 0 749 kerberos.example.com.
 +
}}
 +
Do not forget reverse DNS.
  
Add the client to the Kerberos database:
 
{{hc|kadmin.local: addprinc -randkey host/kbclient.example.com|<nowiki>
 
WARNING: no policy specified for host/kbclient.example.com@EXAMPLE.COM; defaulting to no policy
 
Principal "host/kbclient.example.com@EXAMPLE.COM" created.
 
</nowiki>}}
 
  
Finally, add the client to the Kerberos keytab:
+
== Client configuration ==
{{hc|kadmin.local:  ktadd host/kbclient.example.com|<nowiki>
+
Edit the client's {{ic|/etc/krb5.conf}} to match your server's configuration. You can copy this file from the server, or just set the required realm information.
Entry for principal host/kbclient.example.com with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
 
Entry for principal host/kbclient.example.com with kvno 2, encryption type aes128-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
 
</nowiki>}}
 
 
 
Finally, copy {{ic|/etc/krb5.keytab}} from the server to the client:
 
{{bc|<nowiki># scp kerberos.example.com:/etc/krb5.keytab /etc/krb5.keytab
 
# chmod 600 /etc/krb5.keytab</nowiki>}}
 
  
 +
=== Testing ===
 
You should now be able to get a Kerberos ticket on the client:
 
You should now be able to get a Kerberos ticket on the client:
 
{{hc|$ kinit|<nowiki>
 
{{hc|$ kinit|<nowiki>
Line 140: Line 128:
 
</nowiki>}}
 
</nowiki>}}
  
== Advanced configuration ==
 
=== DNS records ===
 
{{hc|db.example.com|
 
kerberos          A  1.2.3.4
 
_kerberos          TXT "EXAMPLE.COM"
 
_kerberos._udp    SRV 0 0  88 kerberos.example.com.
 
_kerberos-adm._udp SRV 0 0 750 kerberos.example.com.
 
}}
 
 
Do not forget reverse DNS.
 
 
=== Firewall ===
 
{{Accuracy|krb5 documentation says tcp is used on both, though mine is not listening for tcp on 750.}}
 
  
Add ALLOW rules to your firewall for both tcp and udp on ports 88 and 750.
+
== Configuring kadmin ==
 +
You'll need /etc/krb5.conf configured on the kadmin client, and the server's firewall configured for kadmin.
  
 
=== Configuring kadmin ACL ===
 
=== Configuring kadmin ACL ===
Line 196: Line 172:
 
kadmin:
 
kadmin:
 
</nowiki>}}
 
</nowiki>}}
 +
 +
 +
== Service principals and keytabs ==
 +
First, ensure you've configured krb5.conf on all involved machines.
 +
 +
A kerberos principal has three components, formatted as `primary/instance@REALM`. For user principals, the primary is your username and the instance is omitted or is a role (eg. "admin"): `myuser@EXAMPLE.COM` or `myuser/admin@EXAMPLE.COM`. For hosts, the primary is "host" and the instance is the server FQDN: `host/myserver.example.com@EXAMPLE.COM`. For services, the primary is the service abbreviation and the instance is the FQDN: `nfs/myserver.example.com@EXAMPLE.COM`.
 +
The realm can often be omitted, the local computer's default realm is usually assumed.
 +
 +
=== With remote kadmin ===
 +
This is the easier method, but requires you to have configured [[Kerberos#Configuring_kadmin|kadmin]].
 +
 +
Open kadmin as root (so we can write the keytab) on the client, authenticating with your admin principal:
 +
{{hc|client# kadmin -p myuser/admin|<nowiki>
 +
Authenticating as principal myuser/admin with password.
 +
Password for myuser/admin@EXAMPLE.COM:
 +
kadmin:
 +
</nowiki>}}
 +
 +
Add a principal for any services you will be using, eg. "host" for SSH authentication or "nfs" for NFS:
 +
{{hc|kadmin: addprinc -randkey host/kbclient.example.com|<nowiki>
 +
WARNING: no policy specified for host/kbclient.example.com@EXAMPLE.COM; defaulting to no policy
 +
Principal "host/kbclient.example.com@EXAMPLE.COM" created.</nowiki>}}
 +
 +
Save each key to the local keytab:
 +
{{hc|kadmin: ktadd host/kbclient.example.com|<nowiki>
 +
Entry for principal host/kbclient.example.com with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
 +
Entry for principal host/kbclient.example.com with kvno 2, encryption type aes128-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
 +
</nowiki>}}
 +
 +
=== Without remote kadmin ===
 +
 +
Start kadmin on the Kerberos server, using either unix or kerberos authentication:
 +
{{hc|# kadmin.local|<nowiki>
 +
Authenticating as principal root/admin@EXAMPLE.COM with password.
 +
kadmin.local:
 +
</nowiki>}}
 +
 +
Add a principal for any services you will be using, eg. "host" for SSH authentication or "nfs" for NFS:
 +
{{hc|kadmin.local: addprinc -randkey host/kbclient.example.com|<nowiki>
 +
WARNING: no policy specified for host/kbclient.example.com@EXAMPLE.COM; defaulting to no policy
 +
Principal "host/kbclient.example.com@EXAMPLE.COM" created.
 +
</nowiki>}}
 +
 +
Save each key to a new keytab to be transferred to the client:
 +
{{hc|kadmin.local: ktadd -k kbclient.keytab host/kbclient.example.com|<nowiki>
 +
Entry for principal host/kbclient.example.com with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
 +
Entry for principal host/kbclient.example.com with kvno 2, encryption type aes128-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
 +
</nowiki>}}
 +
 +
Finally, copy {{ic|kbclient.keytab}} from the server to the client using SCP or similar, then put it in place with correct permissions:
 +
{{bc|<nowiki># install -b -o root -g root -m 600 kbclient.keytab /etc/krb5.keytab</nowiki>}}
 +
 +
Finally, delete kbclient.keytab from the server and client.
 +
  
 
== SSH Authentication ==
 
== SSH Authentication ==
 +
 +
Use the instructions in [[Kerberos#Service_principals_and_keytabs|Service principals and keytabs]] to create a principal for the "host" service for both client and server, then put the client's keys in the client's keytab and the server's keys in the server's keytab.
  
 
Modify your [[SSH]] server configuration to enable GSSAPI authentication:
 
Modify your [[SSH]] server configuration to enable GSSAPI authentication:
Line 216: Line 248:
 
{{hc|$ kinit myuser@EXAMPLE.COM|Password for myuser@EXAMPLE.COM: ***}}
 
{{hc|$ kinit myuser@EXAMPLE.COM|Password for myuser@EXAMPLE.COM: ***}}
  
Pass the -v option to ssh to make sure it works:
+
Pass the -v option to ssh to watch what's happening:
{{hc|$ ssh kerberos.example.com -v|<nowiki>
+
{{hc|$ ssh sshserver.example.com -v|<nowiki>
 
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
 
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
 
debug1: Next authentication method: gssapi-with-mic
 
debug1: Next authentication method: gssapi-with-mic
Line 223: Line 255:
 
debug1: Delegating credentials
 
debug1: Delegating credentials
 
debug1: Authentication succeeded (gssapi-with-mic).
 
debug1: Authentication succeeded (gssapi-with-mic).
Authenticated to krb5-server ([192.168.100.136]:22).
+
Authenticated to sshserver.example.com ([192.168.100.136]:22).
 
debug1: channel 0: new [client-session]
 
debug1: channel 0: new [client-session]
 
debug1: Requesting no-more-sessions@openssh.com
 
debug1: Requesting no-more-sessions@openssh.com
Line 232: Line 264:
 
</nowiki>}}
 
</nowiki>}}
  
You should now see a host ticket on the client:
+
And you should now see a host ticket on the client:
{{hc|$ klist|<nowiki>
+
{{hc|client$ klist|<nowiki>
 
Ticket cache: FILE:/tmp/krb5cc_1000
 
Ticket cache: FILE:/tmp/krb5cc_1000
 
Default principal: myuser@EXAMPLE.COM
 
Default principal: myuser@EXAMPLE.COM
Line 239: Line 271:
 
Valid starting      Expires              Service principal
 
Valid starting      Expires              Service principal
 
08/30/2017 15:37:40  08/31/2017 15:37:40  krbtgt/EXAMPLE.COM@EXAMPLE.COM
 
08/30/2017 15:37:40  08/31/2017 15:37:40  krbtgt/EXAMPLE.COM@EXAMPLE.COM
08/30/2017 15:53:04  08/31/2017 15:37:40  host/kerberos.example.com@EXAMPLE.COM
+
08/30/2017 15:53:04  08/31/2017 15:37:40  host/sshserver.example.com@EXAMPLE.COM
 
</nowiki>}}
 
</nowiki>}}
  
== NFS ==
+
== NFS Security ==
  
 
First, configure your [[NFS#Server|NFS server]] server. Also see [[NFS/Troubleshooting|NFS Troubleshooting]].
 
First, configure your [[NFS#Server|NFS server]] server. Also see [[NFS/Troubleshooting|NFS Troubleshooting]].
 
Configuring a [[Time#Time synchronization|time sync daemon]] on both the clients and the server is strongly recommended. Clock drift will cause this to break, and the error message will not be helpful.
 
Configuring a [[Time#Time synchronization|time sync daemon]] on both the clients and the server is strongly recommended. Clock drift will cause this to break, and the error message will not be helpful.
  
=== Create service principals ===
+
Use the instructions in [[Kerberos#Service_principals_and_keytabs|Service principals and keytabs]] to create a principal for the "nfs" service for both client and server, then put the client's keys in the client's keytab and the server's keys in the server's keytab.
Create service principals for '''both''' your NFS client and your NFS server on the KDC:
 
{{hc|kadmin.local: addprinc -randkey nfs/nfsclient.example.com|<nowiki>
 
WARNING: no policy specified for nfs/nfsclient.example.com@EXAMPLE.COM; defaulting to no policy
 
Principal "nfs/nfsclient.example.com@EXAMPLE.COM" created.
 
</nowiki>}}
 
 
 
And add to the keytab:
 
{{hc|kadmin.local: ktadd nfs/nfsclient.example.com|<nowiki>
 
Entry for principal nfs/nfsclient.example.com with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
 
Entry for principal nfs/nfsclient.example.com with kvno 2, encryption type aes128-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
 
</nowiki>}}
 
 
 
Then distribute {{ic|/etc/krb5.keytab}} to your NFS clients and server.
 
  
 
=== NFS Server ===
 
=== NFS Server ===
Line 269: Line 288:
 
* sec=krb5p uses kerberos for authentication and encryption.
 
* sec=krb5p uses kerberos for authentication and encryption.
 
{{hc|/etc/exports|<nowiki>
 
{{hc|/etc/exports|<nowiki>
/srv/export *(rw,async,no_subtree_check,no_root_squash,sec=krb5)
+
/srv/export *(rw,async,no_subtree_check,no_root_squash,sec=krb5p)
 
</nowiki>}}
 
</nowiki>}}
  

Revision as of 22:18, 31 August 2017

Kerberos is a network authentication system. See krb5 documentation.

Installation

Install the krb5 package on your clients and server.

It is highly recommended to use a time sync daemon to keep client/server clocks in sync.

If hostname resolution has not been configured, you can manually add your clients and server to the hosts(5) file of each machine. Note that the FQDN (myclient.example.com) must be the first hostname after the IP address in the hosts file.

Server configuration

Domain creation

Edit /etc/krb5.conf to configure your domain:

/etc/krb5.conf
[libdefaults]
    default_realm = EXAMPLE.COM

[realms]
    EXAMPLE.COM = {
        admin_server = kerberos.example.com
        # use "kdc = ..." if the kerberos SRV records aren't in DNS (see Advanced section)
        kdc = kerberos.example.com
        # This breaks krb4 compatibility but increases security
        default_principal_flags = +preauth
    }

[domain_realm]
    example.com  = EXAMPLE.COM
    .example.com = EXAMPLE.COM

[logging]
    kdc          = SYSLOG:NOTICE
    admin_server = SYSLOG:NOTICE
    default      = SYSLOG:NOTICE

This file's format is described in the MIT Kerberos documentation

Create the database:

# kdb5_util -r EXAMPLE.COM create -s
Loading random data                                                             
Initializing database '/var/lib/krb5kdc/principal' for realm 'EXAMPLE.COM',                  
master key name 'K/M@EXAMPLE.COM'
You will be prompted for the database Master Password.                          
It is important that you NOT FORGET this password.                              
Enter KDC database master key: ***
Re-enter KDC database master key to verify: ***

Finally, enable and start the Kerberos services:

# systemctl enable krb5-kdc krb5-kadmind
# systemctl start krb5-kdc krb5-kadmind

Add principals

Start the Kerberos administration tool, using local authentication

# kadmin.local
Authenticating as principal root/admin@EXAMPLE.COM with password.
kadmin.local:

Add a user principal to the Kerberos database:

kadmin.local: addprinc myuser@EXAMPLE.COM
WARNING: no policy specified for myuser@EXAMPLE.COM; defaulting to no policy
Enter password for principal "myuser@EXAMPLE.COM": ***
Re-enter password for principal "myuser@EXAMPLE.COM": ***
Principal "myuser@EXAMPLE.COM" created.

Add the KDC principal to the Kerberos database:

kadmin.local: addprinc -randkey host/kerberos.example.com
WARNING: no policy specified for host/kerberos.example.com@EXAMPLE.COM; defaulting to no policy
Principal "host/kerberos.example.com@EXAMPLE.COM" created.

Finally, Add the KDC principal to the server's keytab:

kadmin.local: ktadd host/kerberos.example.com
Entry for principal host/kerberos.example.com with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/kerberos.example.com with kvno 2, encryption type aes128-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.

You should now be able to get a Kerberos ticket:

$ kinit
Password for myuser@EXAMPLE.COM: ***
$ klist
Ticket cache: FILE:/tmp/krb5cc_1000
Default principal: myuser@EXAMPLE.COM

Valid starting       Expires              Service principal
08/30/2017 14:26:09  08/31/2017 14:26:09  krbtgt/EXAMPLE.COM@EXAMPLE.COM

Firewall

Add ALLOW rules to your firewall for any applicable ports/protocols:

  • 88, TCP and UDP for Kerberos v5
  • 749, TCP and UDP for kadmin if you plan to configure it
  • 750, TCP and UDP for Kerberos v4 if you need backwards compatibility

DNS records

This isn't necessary if you specify the kerberos and kadmin server in each machine's krb5.conf

db.example.com
kerberos.example.com.           A     1.2.3.4
_kerberos.example.com.          TXT   "EXAMPLE.COM"
_kerberos._udp.example.com.     SRV   0 0  88 kerberos.example.com.
_kerberos-adm._udp.example.com. SRV   0 0 749 kerberos.example.com.

Do not forget reverse DNS.


Client configuration

Edit the client's /etc/krb5.conf to match your server's configuration. You can copy this file from the server, or just set the required realm information.

Testing

You should now be able to get a Kerberos ticket on the client:

$ kinit
Password for myuser@EXAMPLE.COM: ***
$ klist
Ticket cache: FILE:/tmp/krb5cc_1000
Default principal: myuser@EXAMPLE.COM

Valid starting       Expires              Service principal
08/30/2017 15:36:10  08/31/2017 15:36:10  krbtgt/EXAMPLE.COM@EXAMPLE.COM


Configuring kadmin

You'll need /etc/krb5.conf configured on the kadmin client, and the server's firewall configured for kadmin.

Configuring kadmin ACL

Create a principal for administration:

kadmin.local:  add_principal myuser/admin@EXAMPLE.COM
WARNING: no policy specified for myuser/admin@EXAMPLE.COM; defaulting to no policy
Enter password for principal "myuser/admin@EXAMPLE.COM": ***
Re-enter password for principal "myuser/admin@EXAMPLE.COM": ***
Principal "myuser/admin@EXAMPLE.COM" created.

Add the user to the kadmin ACL file:

/var/lib/krb5kdc/kadm5.acl
myuser/admin@EXAMPLE.COM *

This file's format is described in the MIT Kerberos documentation

Configure kdc.conf:

/var/lib/krb5kdc/kdc.conf
[kdcdefaults]
    kdc_ports = 750,88

[realms]
    EXAMPLE.COM = {
        database_name = /var/lib/krb5kdc/principal
        acl_file = /var/lib/krb5kdc/kadm5.acl
        key_stash_file = /var/lib/krb5kdc/.k5.EXAMPLE.COM
        kdc_ports = 750,88
        max_life = 10h 0m 0s
        max_renewable_life = 7d 0h 0m 0s
    }

This file's format is described in the MIT Kerberos documentation

Restart the kdc and kadmin daemons:

sudo systemctl restart krb5-kdc krb5-kadmind

You can now use kadmin as your own user, authenticating with kerberos:

$ kadmin
Authenticating as principal myuser/admin@EXAMPLE.COM with password.
Password for myuser/admin@EXAMPLE.COM: ***
kadmin:


Service principals and keytabs

First, ensure you've configured krb5.conf on all involved machines.

A kerberos principal has three components, formatted as `primary/instance@REALM`. For user principals, the primary is your username and the instance is omitted or is a role (eg. "admin"): `myuser@EXAMPLE.COM` or `myuser/admin@EXAMPLE.COM`. For hosts, the primary is "host" and the instance is the server FQDN: `host/myserver.example.com@EXAMPLE.COM`. For services, the primary is the service abbreviation and the instance is the FQDN: `nfs/myserver.example.com@EXAMPLE.COM`. The realm can often be omitted, the local computer's default realm is usually assumed.

With remote kadmin

This is the easier method, but requires you to have configured kadmin.

Open kadmin as root (so we can write the keytab) on the client, authenticating with your admin principal:

client# kadmin -p myuser/admin
Authenticating as principal myuser/admin with password.
Password for myuser/admin@EXAMPLE.COM:
kadmin:

Add a principal for any services you will be using, eg. "host" for SSH authentication or "nfs" for NFS:

kadmin: addprinc -randkey host/kbclient.example.com
WARNING: no policy specified for host/kbclient.example.com@EXAMPLE.COM; defaulting to no policy
Principal "host/kbclient.example.com@EXAMPLE.COM" created.

Save each key to the local keytab:

kadmin: ktadd host/kbclient.example.com
Entry for principal host/kbclient.example.com with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/kbclient.example.com with kvno 2, encryption type aes128-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.

Without remote kadmin

Start kadmin on the Kerberos server, using either unix or kerberos authentication:

# kadmin.local
Authenticating as principal root/admin@EXAMPLE.COM with password.
kadmin.local:

Add a principal for any services you will be using, eg. "host" for SSH authentication or "nfs" for NFS:

kadmin.local: addprinc -randkey host/kbclient.example.com
WARNING: no policy specified for host/kbclient.example.com@EXAMPLE.COM; defaulting to no policy
Principal "host/kbclient.example.com@EXAMPLE.COM" created.

Save each key to a new keytab to be transferred to the client:

kadmin.local: ktadd -k kbclient.keytab host/kbclient.example.com
Entry for principal host/kbclient.example.com with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/kbclient.example.com with kvno 2, encryption type aes128-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.

Finally, copy kbclient.keytab from the server to the client using SCP or similar, then put it in place with correct permissions:

# install -b -o root -g root -m 600 kbclient.keytab /etc/krb5.keytab

Finally, delete kbclient.keytab from the server and client.


SSH Authentication

Use the instructions in Service principals and keytabs to create a principal for the "host" service for both client and server, then put the client's keys in the client's keytab and the server's keys in the server's keytab.

Modify your SSH server configuration to enable GSSAPI authentication:

/etc/ssh/sshd_config
# GSSAPI Options
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes

And modify your client configuration to send GSSAPI requests:

/etc/ssh/ssh_config
Host *
  GSSAPIAuthentication yes
  GSSAPIDelegateCredentials yes

Get a ticket-granting ticket on the client before using ssh:

$ kinit myuser@EXAMPLE.COM
Password for myuser@EXAMPLE.COM: ***

Pass the -v option to ssh to watch what's happening:

$ ssh sshserver.example.com -v
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Delegating credentials
debug1: Delegating credentials
debug1: Authentication succeeded (gssapi-with-mic).
Authenticated to sshserver.example.com ([192.168.100.136]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
Last login: Wed Aug 30 15:52:41 2017 from 192.168.100.1

And you should now see a host ticket on the client:

client$ klist
Ticket cache: FILE:/tmp/krb5cc_1000
Default principal: myuser@EXAMPLE.COM

Valid starting       Expires              Service principal
08/30/2017 15:37:40  08/31/2017 15:37:40  krbtgt/EXAMPLE.COM@EXAMPLE.COM
08/30/2017 15:53:04  08/31/2017 15:37:40  host/sshserver.example.com@EXAMPLE.COM

NFS Security

First, configure your NFS server server. Also see NFS Troubleshooting. Configuring a time sync daemon on both the clients and the server is strongly recommended. Clock drift will cause this to break, and the error message will not be helpful.

Use the instructions in Service principals and keytabs to create a principal for the "nfs" service for both client and server, then put the client's keys in the client's keytab and the server's keys in the server's keytab.

NFS Server

Add a Kerberos export option:

  • sec=krb5 uses kerberos for authentication only, and transmits the data unauthenticated and unencrypted.
  • sec=krb5i uses kerberos for authentication and integrity checking, but still transmits data unencrypted.
  • sec=krb5p uses kerberos for authentication and encryption.
/etc/exports
/srv/export *(rw,async,no_subtree_check,no_root_squash,sec=krb5p)

And reload the exports:

# exportfs -arv

NFS Client

Mount the exported directory:

# mount nfsserver:/srv/export /mnt/

You can add -vv for verbose information, and may need -t nfs4 and -o sec=krb5p or your chosen security option.

Check that it worked with the mount command:

mount | grep krb5
nfsserver:/srv/export on /mnt type nfs4 (rw,relatime,vers=4.1,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=krb5,clientaddr=192.168.100.139,local_lock=none,addr=192.168.100.136)

See also