1
[root@westos mnt]# yum install nfs-utils
[root@westos mnt]# systemctl enable nfs-server
ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.target.wants/nfs-server.service'
[root@westos mnt]# systemctl start nfs-server
[root@westos mnt]# firewall-cmd --permanent --add-service=nfs
success
[root@westos mnt]# firewall-cmd --permanent --add-service=rpc-bind
[root@westos mnt]# firewall-cmd --permanent --add-service=mountd
[root@localhost ~]# firewall-cmd --reload
2共享目录
[root@westos ~]# systemctl status nfs-server
nfs-server.service - nfs server
loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled)
active: active (exited) since sat 2017-06-03 21:04:56 edt; 35min ago
process: 2007 execstart=/usr/sbin/rpc.nfsd $rpcnfsdargs $rpcnfsdcount (code=exited, status=0/success)
process: 2003 execstartpre=/usr/sbin/exportfs -r (code=exited, status=0/success)
process: 2002 execstartpre=/usr/libexec/nfs-utils/scripts/nfs-server.preconfig (code=exited, status=0/success)
main pid: 2007 (code=exited, status=0/success)
cgroup: /system.slice/nfs-server.service
jun 03 21:04:56 westos systemd[1]: starting nfs server...
jun 03 21:04:56 westos systemd[1]: started nfs server.
root@westos ~]# mkdir /piblic 建立共享目录
[root@westos ~]# chmod 777 /public
chmod: cannot access ‘/public’: no such file or directory
[root@westos ~]# chmod 777 /piblic
[root@westos ~]# vim /etc/exportfs
[root@westos ~]# exportfs -rv 重新启动共享目录
/public *(rw,sync) 共享/public给所有人并可写
/public 172.25.0.0/24(sync) 共享给0.0这个网段
/public *.example.com(sync) 共享给example.com域的所有主机
/public 172.25.0.14(ro,sync) 172.25.0.250(rw,sync) 11只读 250可写
/public *(sync,no_root_squash) 共享给所有人,当客户端用root挂载不转化身份
利用kerberos保护nfs输出
在server上
开启kerberos认证,得到ldap用户
[root@localhost ~]# yum install sssd krb-workstation authconfig-gtk -y
[root@localhost ~]# logout
connection to 172.25.254.114 closed.
[kiosk@foundation14 desktop]$ ssh [email protected] -x 打开图形
[email protected]'s password:
last login: sat jun 3 23:48:41 2017 from 172.25.254.14
/usr/bin/xauth: file /root/.xauthority does not exist
[root@localhost ~]# authconfig-gtk 安装认证
[root@localhost ~]# wget http://172.25.254.254/pub/keytabs/server14.keytab -o /etc/krb5.keytab
--2017-06-03 23:59:28-- http://172.25.254.254/pub/keytabs/server14.keytab
connecting to 172.25.254.254:80... connected.
http request sent, awaiting response... 200 ok
length: 1258 (1.2k)
saving to: ‘/etc/krb5.keytab’
100%[==========================================>] 1,258 --.-k/s in 0s
2017-06-03 23:59:28 (190 mb/s) - ‘/etc/krb5.keytab’ saved [1258/1258]
下载认证文件