Introduction
After several attempts at getting nfs and automount directories working on my server deepthot, I’ve decided to KISS. I’m beginning from the beginning and sticking to stuff I know. Get all that working, and then increase the complexity. Here we goSteps
- Create two VMs one for NFS one for a Client
- Create an NFS server V3
- Connect to it with the client
- Set up automount with local files
- Upgrade the NFS to v4
- Install FreeIPA
- Kerberos the NFS
- Configure automount for kerberos nfs
- Switch NFS to NAS
Create VMs
This is really standard stuff, just create a VM using all defaults, which is 1 CPU, 1G core, 16G disk. Grab my ssh certs from github during the install. Log in, and dosudo apt update; sudo apt dist-upgrade -y. Reboot. Make sure you can nfs in.Do the same thing for the other machine.
One odd thing I noticed: when I did the install and rebooted, I wasn’t able to see the dns entry. Earlier this morning I noticed that it showed up after I’d upgraded and then rebooted. Hopefully that will remain true. Sadly not so much. The other machine was already in the system as nfs, I haven’t deleted it and I don’t really know how to remove a machine from FreeIPA yet, so, we’ll make another machine nfs-1.
note: too damn slow. Switch to 2 CPUs.
Create an NFS server
I’ve decided to try this without going for V3 first NFSv4Howto. This, of course, uses the /exports bind for all of the exported directories. Synology doesn’t want to do that, but I think I’m going to try doing it this way since this is how I’ve gotten it to work in the past reliably. We’ll get to that when we finally bring the nfs server into it.OK, now we set up the filesystem on the server. So, on nfs install the nfs server, create the export directory and put it in /etc/fstab
apt install -y nfs-kernel-server
mkdir -p /export/home
echo /home/ /export/home none bind 0 0 >>/etc/fstab
mount -a
root@nfs-1:~# ls -l /export/home
total 0
drwxr-xr-x 1 nfs-1 nfs-1 184 Oct 13 18:07 nfs-1
looks good!
Ok, set up nfs security. We don’t actually need to do anything since what we’re doing just makes the default explicit. However later we will be setting up kerberos, and for that it will need to be turned on. Here’s the command: sed -i '/SVCGSSD/s/"[^"]*"/"no"/' /etc/default/nfs-kernel-serverNext thing is to create the /etc/exports file with the filesystems we want exported. If it was a pre NFSv4 you would only have one export here. Now we have to export the root of the exports. I’ve never been really clear on what is going on here, but here we go. This isn’t idempotent, so beware.
cat <<EOF >>/etc/exports
/export 192.168.0.0/16(rw,fsid=0,no_subtree_check,sync)
/export/home 192.168.0.0/16(rw,nohide,insecure,no_subtree_check,sync)
EOF
BUG? uh huh, turns out 0.0.0.0/0 isn’t working as a netmask. I’m wondering if this has been my problem all along… Remember to check next time you play here. And I did check, it helped some, but it didn’t suddenly start working, continue…NFS isn’t mapping users properly. Googling around, found linuxmint chat that gave me a clue to try this:
sudo mkdir -m 755 -p /var/lib/nfs/rpc_pipefs/nfs
sudo mkdir -p /run/rpc_pipefs/nfs
do chown statd:nogroup /var/lib/nfs/rpc_pipefs /run/rpc_pipefs
Nope, this isn’t working either. I did see some notes in the nfsV4 howto that was mentioning the id mapping wan’t working without kerberos. So, I’m going to continue on following that howto to see if this clears up. First though, taking snapshots of nfs-1 and clientInstall freeipa client on the nfs server and client
Referring to howtoforge we install freeipa client on both of the vms we’re playing with todayhostnamectl set-hostname nfs-1.deepthot.aa
apt-get install freeipa-client oddjob-mkhomedir -y
ipa-client-install --mkhomedir
kinit denebeim
root@nfs-1:~# ipa host-show client.deepthot.aa
Host name: client.deepthot.aa
Principal name: host/client.deepthot.aa@DEEPTHOT.AA
Principal alias: host/client.deepthot.aa@DEEPTHOT.AA
SSH public key fingerprint: SHA256:MT1M9wL8e8tSrn+5RszB9fsbRoe7ArQpIWkLAwddeXE root@client (ssh-rsa), SHA256:LgxSoZbg9KteI0ft/SfrysWvyg/ZG9pL8ByI0clT0nk root@client (ssh-dss),
SHA256:GoAgmh+95/eltBZTmvOq4834fold/ReDklxAu44slqU root@client (ecdsa-sha2-nistp256), SHA256:3U+rUUTOpHzhHi1LqrJHOLb4XnFsOBs7+OJZXK07acM root@client (ssh-ed25519)
Password: False
Keytab: False
Managed by: client.deepthot.aa
So, installing the actual nfs on ipa stuff I’m referring again to using-ipa-to-provide-automount-maps-for-nfsv4-home-directoriesI’m tired of screwing around with synology. I’ve found something that works. Namely:
ipa automountkey-mod default auto.nethome --key=\* --info='-fstype=nfs4,rw,sec=sys,soft,rsize=8192,wsize=8192 h2gt2g.deepthot.aa:/volume1/homes/&'
This is nfs4 without using kerberos. The idmapping seems to be working great. This means the synology is able to do kerberos, but no idea what’s going on. It would be nice to see exactly what messages are being sent and so on, but to be honest I don’t want to screw with wireshark at the moment, and that is probably what it would take.Here is the commands to create the autofs tables
ipa automountlocation-add phoenix
ipa automountmap-add-indirect phoenix --parentmap=auto.master --mount=/nethome auto.nethome
ipa automountkey-add phoenix auto.nethome --key=* --info="-fstype=nfs4,rw,sec=sys,soft,rsize=8192,wsize=8192,no_root_squash h2gt2g.deepthot.aa:/volume1/homes/&"
Adding a new user to the system
Configuration for adding a new user
I’m setting this up so that home directories are automounted. I don’t believe that there’s an easy way to get mkhomedir configure this. What I want to do is make a home directory on the NAS and initialize it from /etc/skel like most programs like adduser and useradd do. To do this I’m going to create an automount entry to mount the root home directories on the nas/volume1/homes to the homes directory in root’s home directory.ipa automountkey-add phoenix auto.direct --key=/root/homes --info='-fstype=nfs4,rw,sec=sys,soft,rsize=8192,wsize=8192,no_root_squash h2gt2g.deepthot.aa:/volume1/homes'
systemctl restart autofs
Adding a new user
Actually adding the user would be, creating the user in ipa, then creating the home directory. This should be able to be done from the root account on any client.echo password|ipa user-add --first='Fnord' --last='Ublech' --password --all fnord
cp -a /etc/skel homes/fnord
chown -R fnord@deepthot.aa: homes/fnord
So, I think we’re done for the moment with NFS. Seems to be working fine.This configuration works
On the synology/volume1/homes *(rw,async,no_wdelay,crossmnt,insecure,no_root_squash,insecure_locks,sec=sys:krb5:krb5i:krb5p,anonuid=1025,anongid=100)
/volume1/video *(rw,sync,no_wdelay,crossmnt,insecure,no_root_squash,insecure_locks,sec=sys:krb5:krb5i:krb5p,anonuid=1025,anongid=100)
/volume1/public *(rw,async,no_wdelay,crossmnt,insecure,no_root_squash,insecure_locks,sec=sys:krb5:krb5i:krb5p,anonuid=1025,anongid=100)
/volume1/music *(rw,async,no_wdelay,crossmnt,insecure,no_root_squash,insecure_locks,sec=sys:krb5:krb5i:krb5p,anonuid=1025,anongid=100)
/volume1/photo *(rw,async,no_wdelay,crossmnt,insecure,no_root_squash,insecure_locks,sec=sys:krb5:krb5i:krb5p,anonuid=1025,anongid=100)root@h2gt2g:/etc#
total 876
drwxr-xr-x 16 root root 4096 Oct 21 19:20 .
drwxr-xr-x 23 root root 4096 Oct 20 09:12 ..
drwxr-xr-x 10 root root 4096 Oct 20 17:39 homes
drwxrwsr-x 4 root media@deepthot.aa 4096 Oct 22 18:50 music
drwxrwsr-x 3 root media@deepthot.aa 4096 Sep 2 22:58 photo
drwxrwsr-x 3 root media@deepthot.aa 4096 Oct 22 18:44 public
drwxrwsr-x 4 root media@deepthot.aa 4096 Oct 22 18:34 video
That configuration is setting everything to have no mucking with the user by nfs. And making the directories group writable and sticky. So, anyone belonging to the media group will be able to write, all files created will be owned by the media group. I don’t know if this will work from windows. I may have to install nfs on it.Written with StackEdit.
No comments:
Post a Comment