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. CSDN-markdown语法之怎样使用LaTeX语法编写数学公式

    文件夹 文件夹 正文 标记公式 行内公式 块级公式 上标和下标 分数表示 各种括号 根号表示 省略号 矢量表示 间隔空间 希腊字母 特殊字符 关系运算符 集合运算符 对数运算符 三角运算符 微积分运算 ...

  2. 使用Sublime Text 2编辑和运行node-webkit应用程序

    开发工具目录结构 --E:\develop\ ----node-webkit-v0.9.2-win-ia32 ----Sublime Text 2.0.2 x64 为Sublime text2构建Bu ...

  3. 王立平--Program Files (x86)

    window7根据系统.program files(x86) 它是应用程序目录,在64下位系统.为了更好的相容性32位程序,在一些安装32位程序(请注意,有些节目自己是32位),将默认被安装progr ...

  4. Linux下的下载工具介绍----aria2

    ariac 项目地址:http://aria2.sourceforge.net/ 下载地址:http://sourceforge.net/projects/aria2/files/stable/ari ...

  5. 成都传智职工high翻竞赛场

    日前,由石羊街道总工会.天府新谷园区党委联合主办的“2013年职工趣味竞赛”盛大开幕.传智播客成都java培训中心员工积极参与,活跃在各大项目的比赛中,员工们用笑脸.身影告诉大家:竞赛场上,我们hig ...

  6. hidden change事件

    原文:hidden change事件 对于隐藏域hidden无法触发onchange的解决方法:在更改此隐藏域的时候,调用下它的onchange方法,使用jquery的话, 就直接加上 $(" ...

  7. Java二叉排序树(转)

    一.二叉排序树定义 1.二叉排序树的定义 二叉排序树(Binary Sort Tree)又称二叉查找(搜索)树(Binary Search Tree).其定义为:二叉排序树或者是空树,或者是满足如下性 ...

  8. VC版八皇后

    一.  功能需求: 1. 可以让玩家摆棋,并让电脑推断是否正确 2. 能让电脑给予帮助(给出全部可能结果) 3. 实现悔棋功能 4. 实现重置功能 5. 加入点按键音效果更佳 二.  整体设计计: 1 ...

  9. CopyOnWriteArrayList源代码阅读器

    java.util.concurrent在相应的并发集合的包中定义的通用集合类,为了有效地处理并发场景.间CopyOnWriteArrayList它是合适ArrayList.顾名思义CopyOnWri ...

  10. C++习题 对象数组求最大值

    Description 建立一个对象数组,内放n(<10)个学生的数据(学号.成绩),设立一个函数max,用指向对象的指针作函数参数,在max函数中找出n个学生中成绩最高者,并输出其学号. In ...