Lab 5 Network File Sharing Services

Goal: Share file or printer resources with FTP, NFS and Samba

Sequence 1: Implementing File Transport Protocol(FTP) Services

Deliverable: A working FTP server accessible to hosts and users. An available, but "invisible" upload directory via FTP.

Instructions:

1. Inventory your system and install packages as necessary. Enable the service at system boot.

The following package(s) are required: vsftpd. Check and install if necessary. Please see the Appendix for help on installing software. Use chkconfig to enable this service.

a. # yum -y install vsftpd

b. # chkconfig vsftpd on

2. Consider and document which access controls are applicable to your service implementation to meet the specified requirements.

Access Control  Implementation
Application  /etc/vsftpd/vsftpd.conf
PAM  /etc/pam.d/vsftpd
xinetd  N/A
tcp_wrappers  linked, use service name vsftpd
SELinux  ensure correct file contexts; change one boolean
Netfilter, IPv6  disregard IPv6 access for now
Netfilter  tcp and udp port 21, and ip_conntrack_ftp.ko

Check which ports are commonly used for your service:

grep 'ftp' /etc/services

Check whether vsftpd is linked, or controlled by another utility that is linked with libwrap.so.

ldd $(which vsftpd) | grep libwrap
strings $(which vsftpd) | grep hosts

Application Specific Security

Inspect configuration files used by your service to see the default access control options. A recommended file to begin your inspection is the initialization script called at system boot.

Compare these defaults to the stated requirements.

SELinux

Determine that vsftpd is an SELinux-targeted service by checking the policy file:

semanage fcontext -l | grep ftp

You can check for SELinux booleans by running:

getsebool -a | grep ftp

To permit "Anonymous Upload":

setsebool -P allow_ftpd_full_access on

If you're unsure about the purpose of these settings, try following up with man pages:

man -k ftp | grep selinux

If the above command fails to indicate a man page, but instead displays an error message with the string "updatedb", then you must run makewhatis &. Please retry the man command as listed above.

3. The vsftpd package provides /var/ftp/ for downloads of files by the anonymous FTP user. It does not set up an upload directory. Configure vsftpd to permit uploads by anonymous users. Prepare a directory named /var/ftp/incoming/ for incoming files. Make the group ownership ftp, and make the permissions 730. Verify the permissions on the new directory.

Also ensure that IP network traffic may pass through the Netfilter rules.

a. Edit the file /etc/sysconfig/iptables-config to automatically insert the Netfilter ftp specific module, and insert a Netfilter rule to permit access to vsftpd. Note: an option may already exist for Netfilter, as in the example listed below.

/etc/sysconfig/iptables-config

IPTABLES_MODULES="ip_conntrack_netbios_ns ip_conntrack_ftp"

# iptables -I INPUT 1 -s 192.168.0.0/24 -p tcp --dport 21 -j ACCEPT

# iptables -I INPUT 1 -s 192.168.0.0/24 -p udp --dport 21 -j ACCEPT

b. # cd /var/ftp

c. # mkdir incoming

d. # chown root:ftp incoming

e. # chmod 730 incoming

f. # ls -ld /var/ftp/incoming

4. In /etc/vsftpd/vsftpd.conf, enable anonymous uploads, enable chown uploads and set the chown username to daemon, and set the anonymous umask to 077. Ensure anonymous users are enabled.

Restart vsftpd.

a. Set the following lines in /etc/vsftpd/vsftpd.conf (most of them should be commented in the file). In addition, anonymous_enable=YES should be set already by default.

anon_upload_enable=YES
chown_uploads=YES
chown_username=daemon
anon_umask=077

b. # service vsftpd restart

5. The result of these changes should be that the anonymous FTP user is able to upload files to /var/ftp/incoming, but cannot download files from that directory or list files in it. This is to stop "warez" traders from using our upload directory as a "drop box" for stolen software or data. Upload a file as the anonymous FTP user. It should end up in /var/
ftp/incoming, owned by user daemon and group ftp, with permissions 600 (readwrite by user daemon only).

6. If you want to access the FTP service from a remote machine, remember that vsftpd uses tcp_wrappers.

a. Add a line like this to /etc/hosts.allow to allow connection from the local subnet:

vsftpd: 192.168.0.

Sequence 2: Implementing Network File Sharing(NFS) Services

Deliverable: A working NFS share of the /home/nfstest/ directory

Instructions:

1. Inventory your system and install packages as necessary. Enable the service at system boot.

The following package(s) are required: nfs-utils. Check and install if necessary. The nfs-utils package provides the nfs and nfslock services. See the Appendix for help on installing software. Use chkconfig to enable this service.

a. # yum -y install nfs-utils

b. # chkconfig nfs on

c. # chkconfig nfslock on

2. Consider and document which access controls are applicable to your service implementation to meet the specified requirements.

Access Control  Implementation
Application  /etc/exports
PAM N/A
xinetd  N/A
tcp_wrappers  /sbin/portmap is compiled with linkwrap.a
SELinux  ensure correct file contexts; no change to booleans
Netfilter, IPv6  disregard IPv6 access for now
Netfilter  tcp and udp ports 111 and 2049 are constant; set other port

Check which ports are commonly used for your service:

grep -E 'portmap|nfs' /etc/services

Check whether NFS programs are linked, or controlled by another utility that is linked with libwrap.so. In this case, it is /sbin/portmap that must be carefully configured with tcp_wrappers.

strings $(which portmap) | grep hosts

Application Specific Security

Inspect configuration files used by your service to see the default access control options. A recommended file to begin your inspection is the initialization script called at system boot.

Compare these defaults to the stated requirements.

SELinux

Determine that NFS, or portmap is an SELinux-targeted service by checking the policy file:

semanage fcontext -l | grep -E 'nfs|portm'

You can check for SELinux booleans by running:

getsebool -a | grep -E 'nfs|portm'

If you're unsure about the purpose of these settings, try following up with man pages:

man -k nfs | grep selinux

If the above command fails to indicate a man page, but instead displays an error message with the string "updatedb", then you must run makewhatis &. Please retry the man command as listed above.

3. In the following steps, you will create a user and configure NFS to share the user's home directory to example.com read-write. Before configuring the NFS server, observe the RPC services you are now running.

a. # rpcinfo -p

b. # showmount -e localhost

4. Ensure Netfilter rules permit access to portmap and your NFS service.

Edit the file /etc/sysconfig/nfs to specify ports to be used by the NFS service, and insert Netfilter rules to permit access to portmap and your NFS service port assignments.

a. /etc/sysconfig/nfs

MOUNTD_PORT="4002"
STATD_PORT="4003"
LOCKD_TCPPORT="4004"
LOCKD_UDPPORT="4004"

b. # iptables -I INPUT -s 192.168.0.0/24 -p tcp --dport 111 -j ACCEPT

c. # iptables -I INPUT -s 192.168.0.0/24 -p udp --dport 111 -j ACCEPT

d. # iptables -I INPUT -s 192.168.0.0/24 -p tcp --dport 4002 -j ACCEPT

e. # iptables -I INPUT -s 192.168.0.0/24 -p udp --dport 4002 -j ACCEPT

f. # iptables -I INPUT -s 192.168.0.0/24 -p tcp --dport 4003 -j ACCEPT

g. # iptables -I INPUT -s 192.168.0.0/24 -p udp --dport 4003 -j ACCEPT

h. # iptables -I INPUT -s 192.168.0.0/24 -p tcp --dport 4004 -j ACCEPT

i. # iptables -I INPUT -s 192.168.0.0/24 -p udp --dport 4004 -j ACCEPT

j. # iptables -I INPUT -s 192.168.0.0/24 -p tcp --dport 2049 -j ACCEPT

k. # iptables -I INPUT -s 192.168.0.0/24 -p udp --dport 2049 -j ACCEPT

l. # service iptables save; restorecon -R /etc/sysconfig

5. Create a test user named nfstest.

a. # useradd nfstest

6. Edit /etc/exports such that /home/nfstest is shared to example.com. See the man page for exports if you are unsure about the appropriate format for entries.

a. /etc/exports should have a line such as this:

/home/nfstest *.example.com(rw,sync)

7. Installation of the NFS server packages configures NFS to start in runlevels 2 through 5, however, as /etc/exports was empty at boot, the nfs and nfslock were not started. Start them now.

Installation of the NFS server packages configures NFS to start in runlevels 2 through 5, however, as /etc/exports was empty at boot, the nfs and nfslock were not started. Start them now.

a. # service nfs start

b. # service nfslock start

8. Observe which RPC services are running now and see if you are exporting /home/nfstest.

a. # rpcinfo -p

b. # showmount -e localhost

9. NFS also uses tcp_wrappers. Allow access to the required services to one of your neighbors or to the 192.168.0.0/24 subnet.

a. Add an entry such as this to the /etc/hosts.allow file:

portmap, mountd: 192.168.0.

10. Work with one or two partners, taking turns mounting each other's shares. Try reading the contents of the share and writing to it as both root and as nfstest (modify the nfstest user's UID and GID to match your partner's nfstest user if they are not the same.) What happens? Why?

a. # mkdir /home/remote

b. # mount stationY:/home/nfstest /home/remote

c. If the nfstest user's UID and GID match that of your partner(s), you should have permission to read/write to the NFS share. If not, you will not be able to access the directory. root should not have access to the NFS share, because of the default option root_squash.

Sequence 3: Implementing a Samba(SMB/CIFS) Server

Deliverable: A working Samba server accessible to several users with smbclient.

Instructions:

1. Inventory your system and install packages as necessary.

Enable the service at system boot.

The following package is required: samba. Check and install if necessary. Please see the Appendix for help on installing software. Use chkconfig to enable this service.

a. # yum -y install samba

b. # chkconfig smb on

2. Consider and document which access controls are applicable to your service implementation to meet the specified requirements.

Complete the access control matrix to be used as an aid while configuring the service:

Access Control  Implementation
Application  /etc/samba/smb.conf
PAM  N/A
xinetd  N/A
tcp_wrappers  N/A
SELinux  ensure correct file contexts; change to one boolean
Netfilter, IPv6  disregard IPv6 access for now
Netfilter  tcp and udp ports 137,138 and 139, tcp port 445

Check which ports are commonly used for your service:

grep -E 'netbio|microsoft-ds' /etc/services

Application Specific Security

Inspect configuration files used by your service to see the default access control options. A recommended file to begin your inspection is the initialization script called at system boot.

Compare these defaults to the stated requirements.

SELinux

Determine that Samba is an SELinux-targeted service by checking the policy file:

semanage fcontext -l | grep sam

You can check for SELinux booleans by running:

getsebool -a | grep sam

To permit access to user home directories:

setsebool -P samba_enable_home_dirs on

If you're unsure about the purpose of these settings, try following up with man pages:

man -k sam | grep selinux

If the above command fails to indicate a man page, but instead displays an error message with the string "updatedb", then you must run makewhatis &. Please retry the man command as listed above.

3. Insert Netfilter rules to permit access to your Samba service port assignments.

a. # iptables -I INPUT 1 -s 192.168.0.0/24 -p tcp --dport 137 -j ACCEPT

b. # iptables -I INPUT 1 -s 192.168.0.0/24 -p udp --dport 137 -j ACCEPT

c. # iptables -I INPUT 1 -s 192.168.0.0/24 -p tcp --dport 138 -j ACCEPT

d. # iptables -I INPUT 1 -s 192.168.0.0/24 -p udp --dport 138 -j ACCEPT

e. # iptables -I INPUT 1 -s 192.168.0.0/24 -p tcp --dport 139 -j ACCEPT

f. # iptables -I INPUT 1 -s 192.168.0.0/24 -p udp --dport 139 -j ACCEPT

g. # iptables -I INPUT 1 -s 192.168.0.0/24 -p tcp --dport 445 -j ACCEPT

h. # service iptables save; restorecon -R /etc/sysconfig

4. Create a group named legal with GID 30000, to which the users karl, joe, mary and jen belong. These users do not yet exist on your system, so you'll need add them too. Add each of these users with a nologin shell. Do not give them passwords! They are permitted access to this system only through Samba.

a. # yum -y install samba-common samba-client samba

b. # service smb start

c. # smbclient -L localhost -N

d. # groupadd -g 30000 legal

e. #
for user in karl joe mary jen
do
  useradd -G legal -s /sbin/nologin $user
done

5. By default, Samba is configured to receive encrypted passwords, but no passwords have been set in /etc/samba/smbpasswd. To test your Samba server, you must run smbpasswd for each user you wish to grant access to your server. Add the users from the previous step, root, and another user of your choosing (e.g., student).

a. Run the following command, and enter a password for each user when prompted.
# for user in karl joe mary jen root student
do
  echo Adding $user to the smbpasswd file...
  smbpasswd -a $user
done

6. Notice the first share defined in /etc/samba/smb.conf, [homes], has no path specified. This share is configured to share a user's home directory if they connect and authenticate. Explore one or two of the user's home directory shares. Upload a file to the joe user's home share.

a. # smbclient //stationX/joe -U joe
Password:
smb> put /etc/hosts hosts
smb> exit
#

Sequence 4: Providing access to a group directory

Scenario: It turns out that in addition to having their own private shares on the server, our four users are part of the same department and require a place to store their departmental files. We will need to set up a Linux group for the users, create a directory for the users to store their content, and configure the Samba server to share the directory.

Deliverable: A Linux directory that only the legal group can use.

A Samba share that only legal group users can access and modify.

Instructions:

1. Create the directory path /home/depts/legal. Set the ownerships and permissions on the directory such that people in the legal group can add/delete files, but others can not. Also set the SGID and Sticky permissions so that the group ownership on all files created in this directory will be set to the group owner of legal and so that one user can not remove another's files.

a. # mkdir -p /home/depts/legal

b. # chgrp legal /home/depts/legal

c. # chmod 3770 /home/depts/legal

2. Create a Samba share called [legal] in /etc/samba/smb.conf. Only the members of the legal group should have write access to the share. In addition, ensure that the files placed in the [legal] share are created with permissions 0660.

a. In the /etc/samba/smb.conf file, place the following after the Share Definitions section (you can simply add this to to bottom of the file):

[legal]
comment = Legal's files
path = /home/depts/legal
public = no
write list = @legal
create mask = 0660

3. Restart the smb service and test users of the legal group (and users not of this group) with smbclient.

a. # service smb restart

b. # smbclient //stationX/legal -U karl

c. # smbclient //stationX/legal -U joe

d. # smbclient //stationX/legal -U mary

e. # smbclient //stationX/legal -U jen

f. # smbclient //stationX/legal -U student%student

g. # smbclient //stationX/legal -U root

RH253读书笔记(5)-Lab 5 Network File Sharing Services的更多相关文章

  1. RH253读书笔记(6)-Lab 6 Implementing Web(HTTP) Services

    Lab 6 Implementing Web(HTTP) Services Goal: To implement a Web(HTTP) server with a virtual host and ...

  2. RH033读书笔记(13)-Lab 14 Network Clients

    Goal: Practice using a variety of tools to transfer files between your system and a remote system. S ...

  3. RH253读书笔记(1)-Lab 1 System Monitoring

    Lab 1 System Monitoring Goal: To build skills to better assess system resources, performance and sec ...

  4. RH253读书笔记(4)-Lab 4 The Domain Name System

    Lab 4 The Domain Name System Goal: To install and configure a DNS server System Setup: Throughout th ...

  5. RH253读书笔记(3)-Lab 3 Securing Networking

    Lab 3 Securing Networking Goal: To build skills with the Netfilter packet filter Sequence 1: Applyin ...

  6. RH253读书笔记(7)-Lab 7 Electronic Mail

    Lab 7 Electronic Mail Goal: To build common skills with MTA configuration Estimated Duration: 90 min ...

  7. RH253读书笔记(8)-Lab 8 Securing Data

    Lab 8 Securing Data Goal: Gain familiarity with encryption utilities Sequence 1: Using SSH keys with ...

  8. RH253读书笔记(2)-Lab 2 System Resource Access Controls

    Lab 2 System Resource Access Controls Goal: To become familiar with system resource access controls. ...

  9. RH253读书笔记(9)-Lab 9 Account Management Methods

    Lab 9 Account Management Methods Goal: To build skills with PAM configuration Sequence 1: Track Fail ...

随机推荐

  1. C#语言基础原理及优缺点

    一.原理: C#是专门为.net程序框架而创造的语言. .net框架有ms的.netFramework:Mono的.NetFramework(也是符合.net IL语言,CTS规范,CLS规范, CL ...

  2. HttpClient(联网)

    抽样: void GameRequest::initRequset(const char* url, cocos2d::CCObject* pTarget, cocos2d::SEL_CallFunc ...

  3. varchar 分享影响记忆 试

    准备数据 sysbench --test=oltp --oltp-nontrx-mode=update_key --mysql-table-engine=innodb --oltp-table-siz ...

  4. JQuery日记_5.13 Sizzle选择器(六)选择器的效率

        当选择表达式不符合高速匹配(id,tag,class)和原生QSA不可用或返回错误时,将调用select(selector, context, results, seed)方法,此方法迭代DO ...

  5. 測试之路3——对照XML文件2

    距离上一篇对照xml文件隔了非常久,并不代表一直做了那么久. 事实上上一次对照xml文件一直出错,事实上我忽略了一个非常easy的问题:我从根文件夹下得到的全部孩子,是这个根下的,而xml文件的组织形 ...

  6. OpenCms创建网站的过程示意图——专用OpenCms人们刚开始学习

    很多人听说过OpenCms,我知道它的强大,只需下载并安装,最后,我们看到了久违OpenCms,我们看到了它的简单的界面,喜悦之后,但难免困惑.如何用这个东西,我如何用它来网站,从哪里开始,无从下手. ...

  7. ORACLE 11G没有备份文件參数文件在异机通过rman备份恢复找回被误删的数据

    背景:          同事误删除线上数据.所以须要从备份中找回数据恢复. 真实屋漏偏逢连夜雨.船迟又遇打头风.前两天备份的磁盘坏块,如今仅仅有rman全备的.bak文件,没有控制文件和參数文件,所 ...

  8. IOT(Index Organized Table)

    我们知道一般的表都以堆(heap)的形式来组织的,这是无序的组织方式.Oracle还提供了一种有序的表,它就是索引组织表,简称IOT表.IOT表上必须要有主键,而IOT表本身不对应segment,表里 ...

  9. BAE3.0搭建wordpress注意

    仅仅是mark一个注意的点,数据库连接时,主机是: /** MySQL主机 */ define('DB_HOST', 'sqld.duapp.com:4050');

  10. Mono for Andriod学习与实践(1)— 初体验

    对于Andriod的开发者来说,相信Java语言是第一选择,可是对于.Net开发者来说,要想利用C#在Andriod平台上开发,Mono提供了相应的开发平台来实现,Mono for Andriod就是 ...