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. js检测浏览器中是否安装了flash播放插件

    这两天工作中需要在网页中嵌入flash小游戏,我使用的是swfobject.js version:1.5.其他方面都很好,唯独版本检测这里一直没有搞通,后来实在无奈之下,改用js来检测浏览器的flas ...

  2. as 的妙用

    个人理解:as跟is is 相当于判断里的“==” 是与否 if(e.OriginalSource is Button) as 一般用来转换另一种object e.OriginalSource as ...

  3. 从零开始学Xamarin.Forms(五) 技巧

    原文:从零开始学Xamarin.Forms(五) 技巧 由于HTML5规范于2014年10月终于定稿,公司.net开发人员较少,国内外已有了较为成熟的UI框架.手机软件硬件的快速发展等等原因,所以我就 ...

  4. cocos2dx的发展的例子2048(加入动画版)

    网上找了很多写作教程2048.只是不知道卡的移动动画,我写了一个完美的动画版少. 开发步骤: 1,一个设计CardSprite类. 2,设计主游戏场景GameScene,实现游戏逻辑,加入动画逻辑. ...

  5. Leet code —Jump Game

    问题叙述性说明: Given an array of non-negative integers, you are initially positioned at the first index of ...

  6. volatile解析(转)

    Java并发编程:volatile关键字解析 volatile这个关键字可能很多朋友都听说过,或许也都用过.在Java 5之前,它是一个备受争议的关键字,因为在程序中使用它往往会导致出人意料的结果.在 ...

  7. Java容器的概要

    [Java流输入/输出原理] 在Jaav程序.对于输入数据/输出操作"流"(stream)时尚:J2SDK它提供了多种 各种各样的"流"类,用于获得不同类型的数 ...

  8. android studio学习

    http://blog.csdn.net/ryantang03/article/details/8948037 http://www.it165.net/pro/html/201109/676.htm ...

  9. DP:树DP

    The more, The Better Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  10. UVa 12459 - Bees' ancestors

    称号:区区女性有父亲和母亲,区区无人机只有一个母亲,我问一个单纯的无人机第一n随着祖先的数量. 分析:递归.Fib序列. 状态定义:建立f(k)和m(k)分别用于第一k雌蜂和雄蜂的数量: 递推关系:f ...