kerberized NFS Server Linux Simple way to setup

NFS – Network File system is used to provide file sharing with in the Unix / Linux environments. kerberized NFS server also used for sharing the directories across the Unix / Linux Platforms. We assume that you already have an kerberos server  in place.  

Why we have to use kerberized NFS Server

  • NFS Server without kerberos is not secure
  • NFS share can be accessed by multiple users from NFS client because there is no user level authentication when not using kerberos
  • Wihtout Kerberos NFS Server and client communication is not encrypted 
  • Kerberos will provide an token based authentication
  • NFS with kerberos will use Keytab file to authenticate securely
  • All the communication from client to server fully encrypted


  1. Kerberos Server for token issue authority
  2. Keytab Files
  3. Kerberos principles should be in place (if you want to use krb5p authentication method)
  4. LDAP server for user authentication along with kerberos
  5. NFS Server should be part of LDAP client and Kerberos Client
  6. Both the machines NFS Server and NFS Client should be part of kerberos clients
  7. DNS name resolution should be in working condition (In case of NO DNS name resolution, We will add hosts file entries) Master DNS Setup Guide
  8. NFS server and NFS client should be in sync with NTP server (Should be NTP clients)

Scenario 1: We can install DNS, Kerberos, KDC server, 365 Directory Service, Token issue authority and LDAP. We use this single server as a main server.

Scenario 2: We can install and configure One DNS server, One Kerberos Server and One LDAP Server separately. This Scenario required more hardware resource but performance will be good. 

why i am explaining above two scenario’s because we are going to see the kerberized NFS with single server all services included in one.

Environment :

Server 1 : DNS, Kerberos, 365 Directory Services and LDAP service

Server 2 : NFS Server

Server 3 : NFS Client

Main Server Side in Kerberos Server Side

We have to generate keytab files and add NFS principles in kerberos server. 

# kadmin
Authenticating as principal root/admin@ARKIT.CO.IN with password.
Password for root/admin@ARKIT.CO.IN: kerberos
kadmin: addprinc -randkey nfs/
kadmin: addprinc -randkey nfs/
kadmin: ktadd nfs/
kadmin: ktadd nfs/
kadmin: quit
[root@TechTutorials ~]# cp /etc/krb5.keytab /var/www/html/keytabs/nfserv.keytab
[root@TechTutorials ~]# cp /etc/kerb5.keytab /vat/www/html/keytabs/nfsclient.keytab

Keytab file should be available for download

NFS Server Side Configuration

[ ~]# yum install sssd* authconfig-gtk krb5-workstation
[ ~]# yum install nfs*

After installing above packages we have to run below command in GUI interface

[]# system-config-authentication

Add server to Kerberos client kerberized NFS server

Provide the details

User Account Database: LDAP

LDAP Search Base DN: DC=arkit,

LDAP Server: ldap:// Or ldaps://

Use TLS encryption connections

Ldap Certification Authentication

Authentication Method: Kerberos Password

KDC’s :

## Download keytab file
[ ~]# wget -O /etc/krb5.keytab
[ ~]# vim /etc/sysconfig/nfs
## Default line number 13


## Enable and Start NFS Server and NFS Secure Server
[ ~]# systemctl enable nfs-secure.service
[ ~]# systemctl start nfs-secure.service
[ ~]# systemctl enable nfs-server.service
[ ~]# systemctl start nfs-server.service
[ ~]# systemctl enable nfs-secure-server.service
[ ~]# systemctl start nfs-secure-server.service

## Create Directory to share using NFS
[ ~]# mkdir /nfssecure

## Change Directory ownership
[ ~]# chown ldapuser1 /nfssecure

## Applu SELinux Policy to Directory
[ ~]# semanage fcontext -a -t public_content_rw_t "/nfssecure(/.*)?"
[ ~]# restorecon -R /nfs
[ ~]# setsebool -P nfs_export_all_rw on
[ ~]# setsebool -P nfs_export_all_ro on

Now Create NFS export and export it

[ ~]# vim /etc/exports

/nfssecure *,sec=krb5p)


The security option accepts four different values:
sec=sys (no Kerberos use)
sec=krb5 (Kerberos user authentication only)
sec=krb5i (Kerberos user authentication and integrity checking)
sec=krb5p (Kerberos user authentication, integrity checking and NFS traffic encryption)
If you want to use sec=sys, you also need to run

# setsebool -P nfsd_anon_write 1

Now restart NFS services to reflect the changes

[ ~]# systemctl restart nfs-server.service
[ ~]# systemctl restart nfs-secure-server.service
[ ~]# systemctl restart nfs-secure.service

Enable Firewall ports to communicate with NFS clients

[ ~]# firewall-cmd --permanent --add-service=nfs
[ ~]# firewall-cmd --permanent --add-service=mountd
[ ~]# firewallc-cmd --permanent --add-service=rpc-bind

In order to complete Kerberized NFS Server configuration, We are done in NFS Server we have to switch to NFS client

NFS Client Side configuration

Now start the NFS client side setup. We have to join NFS client also as LDAP and Kerberos Client

repeat first step from NFS server configuration

## Download keytab file
[ ~]# wget -O /etc/krb5.keytab
[ ~]# vim /etc/sysconfig/nfs
## Default line number 13


[ ~]# yum install nfs-utils*
[ ~]# systemctl enable nfs-secure.service
[ ~]# systemctl start nfs-secure.service
[ ~]# mkdir /mnt/nfsmount

Now edit fstab configuration file to mount NFS share permanently

[ ~]# vim /etc/fstab /mnt/nfsmount nfs defaults,sec=kerb5p,v4.2 0 0


[ ~]# mount -a

Now login as ldapuser1 and try to access the nfssecure share it will be accessible.  You can also write data to that share path.


kerberized NFS server is highly secured and encrypted communication. NFS kerberized share can’t be accessible by other users who does not have  permission to NFS share within the same client.

Thanks for the read please provide your valuable comments on the same

Thanks for your wonderful Support and Encouragement

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published. Required fields are marked *