RHEL6 的RHCE考试分为RHCSA和RHCE两部分
考试时间:
RHCSA 2个半小时 总分300分,210分pass
RHCE 2个小时 总分300分,210分pass
考试环境:
考试为上机考试,在一台真实机系统中,已经预安装好虚拟机,要求所有的考试题必须在虚拟机中完成。
网络必须配置好,如果从网络不能被访问到,则考试也不能通过。
你可以用真实机来验证虚拟机中的考试实验是否正确完成
Exam Introduction
·Task-oridnted examination
·Only examine the RESULT,not the process
·All results MUST be valid after reboots
·RHCAS FOCUS ON System Administration
·RHCE FOCUS ON Services Management
Exam Tips
·Setup your networking as instructed,there is no guessing
·Configure iptables as instructed,do not be hard on yourself
·You can change language during exam anytime you want
·All packages in OS DVD are provided already, so just use it
Exam Tips
·Aphysical machine provided for each examinee,inside is v virual machine
—Physical machine used to read tasks
—Virtual machine used to answer questions
·Make sure use the right network mask,there may be any class of IP network
—Some must be open to your server(VM)
—Some must be denied to your server(VM)
·Smile and ask the examiner if you have questions,he/she wants you to pass the exam
1、Topic:Access Exam Tasks
·Break into your system
—Use single user mode to retrieve root password
·Configure your networking
—Remember the 7 elements to setup Linux networking
·IP: 192.168.0.100+X
·Network: 255.255.255.255.0
·Gateway: 192.168.0.254
·DNS: 192.168.0.254
·DNS Suffix: example.com
·Hostname: serverX.example.com
·Do not forget the local resolver
service NetworkManager stop
chkconfig NetworkManager off
chkconfig --list NetworkManager
system-config-network:
cat /etc/resolv.conf 检查DNS
vim /etc/hosts
192.168.0.112 server12.example.com s12
检查 dig server12.example.com
ping server12.example.com
上午RHCSA需配置好静态IP后才能看到考题,题目中未提及防火墙,但默认开启,由于有ftp/http服务的题。最好iptables -F,service iptables save 清空并保存防火墙!!!
下午RHCE考试使用DHCP,无需配静态,但需重新配yum源。下午服务题多,需清空并保存iptables后,使用REJECT。
2、Topic:Configure Static Routes
·Setup a static route for 10.0.0.0/8,all network packets go to 192.168.0.X+30
·Setup a static route for 172.16.0.0/16,all network packets go to 192.168.0.X+60
·Setup a static route for 192.168.7.0/24,all network packets go to 192.168.0.X+90
方法一:
vim /etc/sysconfig/static-routes
any net 10.0.0.0/8 gw 192.168.0.42
any net 172.16.0.0/16 gw 192.168.0.72
any net 192.168.7.0/24 gw 192.168.0.102
service network restart
方法二:
vim /etc/sysconfig/network-scripts/route-eth0
10.0.0.0/8 via 192.168.0.42
172.16.0.0/16 via 192.168.0.72
192.168.7.0/24 via 192.168.0.102
service network restart
检查 ip route 、 route -n
3、Topic:Manage Software
·Setup yum repo to use
http://instructor.example.com/pub/rhel6/dvd as your primary RPM source
·Install vsftpd package
·从ftp://instructor.example.com/pub/misc/ 下载相应的RPM包,并正确升级内核为2.6.36-71.7.1.el6
·取消内核启动参数quiet
·添加内核参数mylove=forever
·确定可以通过/proc/cmdline得到验证
vim /etc/yum.repos.d/rhel6.repo
[rhel6]
name = rhel6 repo
baseurl = http://instructor.example.com/pub/rhel6/dvd
gpgcheck = 0
enabled = 1
yum clean all
yum list
yum install vsftpd (yum install lftp)
lftp instructor.example.com/pub/misc/
ls
get
yum localinstall kernel-2.6.32-71.7.1.el6.x86_64.rpm
yum localinstall kernel-firmware-2.6.32-71.7.1.el6.noarch.rpm
或
rpm -rvh kernel-2.6.32-71.7.1.el6.x86_64.rpm
rpm -ivh kernel-firmware-2.6.32-71.7.1.el6.noarch.rpm
vim /boot/grub/menu.lst
删除quiet 添加 mylove=forever
init 6
cat /proc/cmdline
4、Topic:User Management
·添加3个用户,frodo,sam,pippin
·密码都为redhat,密码有效期为90天
·pippin用户的ID特定为10000
·pippin不能使用交互式shell登录
·添加一个组,share,组ID为20000
·要求frodo,sam用户的附加组为share组
useradd frodo
useradd frodo
useradd -u 10000 -s /sbin/nologin pippin
echo redhat | passwd - -stdin frodo
echo redhat | passwd - - stdin sam
echo redhat | passwd --stdin pippin
passwd -x 90 frodo
passwd -x 90 sam
passwd -x 90 pippin
groupadd -g 20000 share
usermod -a -G share frodo
usermod -a -G share sam
cat /etc/group
5、Topic:File System Permission 1
·创建/file文件,属于root用户,share组
·root用户可以读写此文件
·share组成员可以读此文件
·其他用户不能访问此文件
·另外,frodo用户可以读写此文件
·sam用户不能访问此文件
touch /file
ll /file
chgrp share /file
chmod 640 /file
ll /file
setfacl -m u:frodo:rw- /file
setfacl -m u:sam:--- /file
getfacl /file
6、Topic:File System Permissiom 2
·在/下创建一个目录,名为share
·要求所属组为share组,组成员可以读写此目录
·其他用户没有任何权限
·同组成员在目录下创建的文件和子目录的所属组也自动为share组
·在/share中,用户不能删除其他用户的文件
mkdir /share
ll -d /share
chgrp share /share
chmod 770 /share
chmod g+s /share
chmod o+t /share (chmod 3770 /share)
7、Topic:File System Searching
·查找/var目录中属于root用户但不属于root组的所有文件(不包括目录)
·拷贝到bakcup中
mkdir /backup
find /var -user root -not -group root -type f -exec cp -p {} /backup \;
ll /backup
·找出/var目录中大于5M的文件
·制作成列表文件: /fsinfo.txt
find /var -size +5M > /fsinfo.txt
8、Topic:File Searching
·过滤/etc/vsftpd/vsftpd.conf文件中所有的非注释行,并且该行包含yes或YES字符,将结果保存到/root/gotit.txt文件中
·从文件/usr/share/dict/words中找出包含love的行,追加到/root/gotit.txt文件中
grep -v '^#' /etc/vsftpd/vsftpd.conf | grep -v '^$' | grep -i yes > /root/gotit.txt
grep love /usr/share/dict/words >> /root/gottit.txt
或
cat /usr/share/dict/words | grep love >> /root/gotit.txt
9、Topic:Tecurring Tasks
·用户frodo配置计划任务
·每天的23:55,执行echo test 命令
·禁止sam用户使用计划任务
·用户root创建计划任务
·在每月前10天的2:30
·执行/bin/echo areyouok?
·仅允许root和frodo 用户能创建计划任务
su frodo
crontab -e
55 23 * * * echo test
su -
crontab -e
30 2 1-10 * * /bin/echo areyouok?
vim /etc/cron.allow
root
frodo
crontab 计划任务
* | * | * | * | * |
分 | 时 | 日 | 月 | 周 |
0-59 | 0-23 | 1-31 | 1-12 | 0-6 |
*/5 每5分钟
10、Topic:Partiting
·添加一个新的物理分区,大小70M,文件系统vfat,挂载到/mnt/windows上
·添加一个新的物理分区,大小150M,文件系统ext3,挂载到/mnt/moveaway上
·创建一个300M的交换分区并使用,不要影响原有的交换分区
·连接到iscsi存储,地址是192.168.0.254,使用一半空间做成ext3文件系统,挂载到/mnt/iscsi上
·以上全部要求使用UUID进行挂载
fdisk -cu /dev/sda →p→n→p→3→回车→+700M→p→t→3→l→b→p→w
partx -a dev/sda
mkfs.vfat /dev/sda3
blkid 查看UUID
vim /etc/fstab
UUID号 /mnt/windows vfat defaults 0 0
mkdir /mnt/windows
mount -a
df -Th
********************************************************
添加一个新的物理分区,大小150M,文件系统ext3,挂载到/mnt/moveaway上
已经用了3个主分区,所以分扩展分区。
fdisk -cu /dev/sda
p n e(扩展分区) p
n 回车 +150M p w
partx -a /dev/sda
mkfs.ext3 /dev/sda5
blkid
vim /etc/fstab
UUID="XXX" /mnt/moveaway ext3 defaults 0 0
mkdir /mnt/moveaway
mount -a
df -Th
**********************************************************
·创建一个300M的交换分区并使用,不要影响原有的交换分区
free -m
fdisk -cu /dev/sda
p n +300M t 6 l 82(交换分区) p w
partx -a /dev/sda
mkswap /dev/sda6 激活swap分区
vim /etc/fstab 写入fstab
UUID="XXX" swap swap defaults 0 0
swapon -a 开启swap分区
swapon -s 查看swap分区
free -m
*************************************************************
连接到iscsi存储,地址是192.168.0.254,使用一半空间做成ext3文件系统,挂载到/mnt/iscsi上
man iscsiadm
/EXAMPLES
iscsiadm - -mode discoverydb - - type sendtargets - - portal 192.168.0.254 - - discover
chkconfig iscsid on
iscsiadm - - mode node - - targetname iqn.2010-09.com.example:rdisks.server12 - - portal 192.168.0.254 - - login
fdisk -l
fdisk -cu /dev/sdb
p n p 1 +17M p w
partx -a /dev/sdb
mkfs.ext3 /dev/sdb1
blkid
vim /etc/fstab
mkdir /mnt/iscsi
mount -a
df -Th
11、Topic:Encrypted Partition
·添加一个新的物理分区
·大小50M
·类型ext4,卷标为sheep
·并且加密,密码为:youdontknowit
应用程序-系统工具-磁盘实用工具
Applications—System Tools —Disk Utility
Topic:Archiving and Compressing
·将/etc目录打包并压缩成bzip2格式和xz格式,备份到/mnt/moveaway目录中,起名为etc.tar.bz2和etc.tar.xz
·比较连个文件大小,选择压缩包好的,为其建立软连接为:betterzip
·将/home目录打包并压缩成gzip格式,备份到/mnt/moveaway目录中,起名home.tar.gz
man tar
cd /mnt/moveaway
tar jcvf etc.tar.bz2 /etc
tar Jcvf etc.tar.xz /etc
ll
man ln
ln -s etc.tar.xz betterzip
******************************************************
·将/home目录打包并压缩成gzip格式,备份到/mnt/moveaway目录中,起名home.tar.gz
cd /mnt/moveaway
tar zcvf home.tar.gz /home
ll
12、Topic:LVM
·把名为home的逻辑卷容量增加到500M,不能破坏原有文件,完成后将df命令结果存储在/root/lvmhome.txt中
·把名为home的逻辑卷容量缩小到150M,不能破坏原有文件,完成后将df命令结果追加到/root/lvmhome.txt中
—(可以考虑单用户模式)
·创建一个卷组myvg
·Physical Extend 大小为8M
·分配一个50个PE的逻辑卷mylv
·制作为ext4文件系统,挂载到/mnt/mylv下
lvs
ll home
df -Th
lvresize -L 500M /dev/mapper/vgsrv-home
lvs 、df -Th
resize2fs -p /dev/mapper/vgsrv-home
ll /home 查看文件是否依然存在
*************************************************************
·把名为home的逻辑卷容量缩小到150M,不能破坏原有文件,完成后将df命令结果追加到/root/lvmhome.txt中
—(可以考虑单用户模式)
umount /home
resize2fs /dev/mapper/vgsrv-home 150M
e2fsck -f /dev/mapper/vgsrv-home
resize2fs /dev/mapper/vgsrv-home 150M
lvresize -L 150M /dev/mapper/vgsrv-home
mount -a
df -Th
ll /home
df >> /root/lvmhome.txt
cat /root/lvmhome.txt
*************************************************************
·创建一个卷组myvg
·Physical Extend 大小为8M
·分配一个50个PE的逻辑卷mylv
·制作为ext4文件系统,挂载到/mnt/mylv下
vgdisplay (先)
先分一个比PE*n 大的空间,转换成8e(Linuix Lvm)
pvcreate /dev/sda8
vgcreate -s 8M myvg /dev/sda8
lvcreate -l 50 -n mylv myvg
mkfs.ext4 /dev/myvg/mylv
vim /etc/fstab
/dev/myvg/mylv /mut/mylv ext4 default 0 0
mkdir /mnt/mylv
mount -a
13、Topic:Mounting File System
·下载ftp://instructor.example.com/pub/misc/cd.iso 至/opt,命名为mycd.iso
·挂载到/mnt/cd目录上
·挂载instructor.example.com主机中的nfs共享/var/ftp/pub至/mnt/pub
cd /opt
lftp instructor.example.com/pub/misc
get cd.iso
mv cd.iso mycd.iso
man mount
vim /etc/fstab
/opt/mycd.iso /mnt/cd iso9660 defaults,loop 0 0
df -Th
*****************************************************
·挂载instructor.example.com主机中的nfs共享/var/ftp/pub至/mnt/pub
Chkconfig --list nfs
Service nfs start
chkconfig nfs on
showmount -e instructor 查看NFS共享(yum install nfs*)
vim /etc/fstab
instructor.example.com:/var/ftp/pub /mnt/pub nfs defaults 0 0
mount -a
df -Th
Topic:Centralizing Account Management 1
·添加NIS认证方式
·NIS域的名称为:notexample
·NIS用户名成为:guest20XX,密码为password
·配置autofs
·实现guest20XX登录成功后有家目录/home/guests/guest20XX可以使用
·家目录已经在instructor.example.com上使用nfs共享为:/home/guest20XX
·配置为通用形式,所有NIS用户都可以访问家目录
yum install yp* (ypbind)
getent passwd 或 ypcat passwd
vim /etc/auto.master
/home/guests /etc/auto.home
vim /etc/auto.home
* instructor.example.com:/home/guests/& (通用形式)
(guests2011 instructor.example.com:/home/guests/2011) 只能切单个用户
chkconfig autofs on
service autofs stop
service autofs start
su - guest2011
pwd
14、Topic:Centralizing Account Management 2
·取消NIS认证方式
·添加LDAP认证方式
·LDAP服务器地址为:instructor.example.com
·LDAP服务器索引根为:dc=example,dc-com
·LDAP用户名称为:ldapuserX,密码为:password
·CA证书下载路径:
—http://instructor.example.com/put/EXAMPLE-CA-CERT
·检查autofs配置,是否满足LDAP用户家目录自动挂载
·要求ldapuserX登录后有家目录/home/guests/ldapuserX可以使用
·家目录已经在instructor.example.com上使用nfs共享为:/home/ldapuserX
·配置为通用形式,所有LDAP用户都可以访问家目录
authconfig-tui
use LDAP/use LDAP Authentication
use TLS
server:ldap://instructor.example.com
Base DN:dc=example,dc=com
下载证书到/etc/openldap/cacerts
cat/etc/openldap/ca
lftp instructor.example.com/pub
get EXAMPLE-CA-CERT
cacertdir_rerash ./
确定
chkconfig ssd on
chkdonfig --list ssd
vim /etc/auto.master
/home/guests /etc/auto.home
vim /etc/auto.home
* instructor.example.com:/home/guests/& (通用形式)
(guests2011 instructor.example.com:/home/guests/2011) 只能切单个用户
chkconfig autofs on
service autofs stop
service autofs start
用户名:ldapuserX 密码:password
查看用户信息:getent passwd ldapuserX
15、Topic:Centralizing Account Management 3
·修改系统为LDAP+Kerberos认证方式
·Kerberos的域名称为:EXAMPLE.COM
·Kerberos服务器地址为:instructor.example.com
·Kerberos管理器地址为:instructor.example.com
·用户名称不变:ldapuserX
·Kerberos密码为:Kerberos
authconfig-tui
use LDAP/use kerberos
用户名:ldapuserX 密码:kerberos
Realm:EXAMPLE.COM
KDC:instructor.example.com
Admin Server:instructro.example.com
16、Topic:Scripting
·写一个脚本/root/myprog
·当输入参数CPU时,脚本输出CPU Info:,并CPU类型
·当输入参数为Memory时,脚本输出Memory Info:,并内存使用情况
·当输入参数为Disk时,脚本输出Disk Info:,并磁盘空间使用情况
·当输入参数为Process时,脚本输出Process Info:,并系统当前所有进程列表
·而当输入错误的参数或无参数时,输出:
Usage:/root/myprog CPU|Memory|Disk|Process.
cat /etc/init.d/rsyslog 复制case开始 esac结束
cp /etc/init.d/rsyslog /root/myprog
vim /root/myprog
case "$1" in
CPU)
echo "CPU Info:"
grep cpu /proc/cpuinfo
;;
Memory)
echo "Memory Info:"
free -m
;;
Disk)
echo "Disk info:"
df -Th
;;
Process)
echo "Process Info:"
ps -aux
;;
*)
echo "Usage:/root/myprog CPU|Memory|Disk|Process."
exit 3
esac
17、Topic:OS Basic Configuration
·配置机器与instructor.example.com同步时间
·SELinux 设置为enforcing模式
·打开IP转发功能
·关闭计算机的ping相应
system-config-date
vim /etc/sysconfig/selinux
getenforce
setenforce 1
getenforce
sysctl -a| grep ignore_all
vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
net.ipv4.icmp_echo_ingore_all =1
sysctl -p
18、Topic:Service Management
·Service Software Installation
·Start Service
·Auto-start Service
·Setup IP countrol over Service
服务网段列表
·example.com域的IP段为:192.168.0.0/24
·remote.test域的IP段为:192.168.1.0/24
19、Topic:Centralizing logging
·在serverX.example.com上配置rsyslog服务,接收来自192.168.0.0/24网段机器中所有的日志
·在desktopX.example.com上配置rsyslog服务,发送所有user类型,并且敏感度在info之上的所有日志到serverX.example.com
—此任务比较特殊,请在desktopX.example.com上答题
vim /etc/rsyslog.conf
去掉UDP 和 TCP 前的#
#Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
#Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514
netstat -lntup | grep 514
iptables -F
service iptables save
iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 514 -j REJECT
iptables -A INPUT -s 192.168.1.0/24 -p udp --dport 514 -j REJECT
service iptables save
chkconfig rsyslog on
客户端
vim /etc/rsyslog.conf
添加
user.info @server12.example.com
(类型.敏感度) (一个@是udp ,两个@是tcp)
service rsyslog restart
客户端测试:logger "this is a test message"
服务器端监控: tail -n0 -f /var/log/messages
(客户端需能解析服务器端 vim )
vim /etc/hosts
192.168.0.112 server12.example.com
20、Topic:SSH Server SSHD
·配置ssh服务,允许本机用户可以在example.com域登录访问,拒绝remote.test域访问
·使用student用户配置钥匙对,可以以root用户无密码登录虚拟机(Key-based Authentication)
—此任务比较特殊,请在desktopX.example.com上答题
yum install openssh*
chkconfig sshd on
chkconfig --list sshd
iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 22 -j REJECT
service iptables save
Su student
ssh-keygen 生成key
ssh-copy-id root@server12.example.com
21、Topic:FTP Server
·配置ftp服务器仅允许匿名用户可以从/var/ftp/pub目录下载资料
·拒绝所有remote.test域的访问
service vsftpd restart
chkconfig vsftpd on:
iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 21 -j REJECT
service iptables save
vim /etc/vsftpd/vsftpd.conf
local_enable= NO
service vsftpd restart
22、Topic:NFS Server Network File Sharing Services
·配置nfs服务器
·将/general目录以读写方式共享给example.com域
·客户端以root用户访问是保持原身份
·将/general目录以只读方式共享给remote.test域
·客户端以root用户访问时压缩其权限
yum list nfs*
service nfs restart
chkconfig nfs on
mkdir /general
vim /etc/exports
/general 192.168.0.0/255.255.255.0(rw,no_root_sqash) 192.168.1.0/255.255.255.0(ro) 不支持缩写
service nfs reload
cd /net/server12
23、Topic:Sambna Server
·配置Samba服务器
·工作组名为:love
·共享/gengeral,共享名称share,要求能被samba客户端浏览
·建立3个samba用户:frodo,sam,pippin
·frodo对此共享有读写权限
·sam和pippin对此共享有只读权限
·所有用户的samba密码为sambapwd
·拒绝来自remote.test域的访问
yum grouplist | grep -I file
yum groupinfo 'CIFS file server'
yum groupinstall 'CIFS file server'
yum grouplist | grep -i cifs
yum groupinstall cifs*
service smb restart
service nmb restart
chkconfig smb on
chkconfig nmb on
iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 137:139 -j REJECT
iptables -A INPUT -s 192.168.1.0/24 -p udp --dport 137:139 -j REJECT
iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 445 -j REJECT
iptables -A INPUT -s 192.168.1.0/24 -p udp --dport 445 -j REJECT
service iptables save
vim /etc/samba/smb.conf
workgroup=love
[share]
comment = my share
path = /general
write list = frodo
browseable = yes
ls -ldZ /general
chcon -R -t samba-share-t /general/ 命令在smb.conf 文件可查找
semanage fcontext -a -t samba share -t "/general(/.*)?" (man semanage)
ls -Z /general
smbpasswd -a frodo pdbedit -L
smbpasswd -a sam
smbpasswd -a pippin
service smb restart
service nmb restart
smbclient -L //server12.example.com 查看共享
smbclient -U frodo //server12.example.com/share
chmod 777 /general/
24、Topic:SMTP Server
·配置邮件发送服务器
·要求可以接受到各地的邮件寄送请求
·仅允许example.com域的所有机器可以通过此邮件服务器转发邮件出去
·拒绝remote.test的邮件转发
·配置电子邮件别名,要求发给itadmin的邮件,转发给frodo和root用户
yum list postfix
chkconfig --list postfix
iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 25 -j REJECT
service iptables save
postconf | grep inet
postconf -e "inet_interfaces = all" 回车
service postfix restart
或者 vim /etc/postfix/main.cf inet_interfaces = all
postconf | grep network 查看允许的网段
vim /etc/aliases
itadmin:frodo,root
postalias /etc/aliases
测试
mail itadmin@server12.example.com
subject:XXX
XXXX
. 回车
mail (收信)
25、Topip:Web Server
·web服务器http://serverX.example.com ,首页为:配置:ftp://instructor.example.com/pub/misc/page.html
·拒绝remote.test域访问
yum grouplist | grep -i web
yum groupinstall `Web server`
service httpd restart
chkconfig httpd on
iptables -A INPUT -s 192.168.1.0/24 -p tcp --doprt 80 -j REJECT
service iptables save
cd /var/www/html
lftp instructor.example.com/pub/misc
get page.html
mv page.html index.html
**********************************************************
·配置web虚拟主机, http://wwwX.example.com ,发布目录为:/virt; 首页为:ftp://instructor.example.com/pub/misc/virt.html
·frodo用户可以在/virt,目录中发布网站信息
·只有本机可以访问该网站
mkdir /virt
ls -Zd /virt
semanage fcontext -a -t httpd-sys-content-t "/virt (/.*)?"
restorecon -R /virt/
ls -Z 查看
cd /virt 下载页面 改为 index.html
vim /etc/httpd/conf/httpd.conf
取消# NameVirtualHost *:80
把默认目录添加进来
DocumentRoot /var/www/html
serverName server12.example.com
第二个目录
DocumentRoot /virt
ServerName wwwd.example.com
serviec httpd restart
ll -d /virt 查看权限
chown frodo /virt
vim /etc/httpd/conf/httpd.conf
在虚拟目录加
Ordre allow,deny
Allow from 192.168.0.112
Allow from 127.0.0.1
service httpd restart
links -dump XXXX 测试
*********************************************************
·下载ftp://instructor.example.com/pub/misc/secret.html 文件并发布
·要求所有UID大于500的本地用户和新web用户wwwuser可以通过web界面身份认证后,在这里访问到: http://serverX.example.com/mystuff/secret.html
·本地用户的web密码和系统密码一样,wwwuser的密码为password
htpasswd -cm /etc/httpd/htpasswd wwwuser
c:第一次创建 m:md5 第二次只用 -m
password:XXXX
chmod 640 /etc/httpd/conf/htpasswd
chown apache.apache /etc/httpdconf/htpasswd
cut -d: -f1-2 /etc/shadow >> /etc/httpd/conf/htpasswd
删除没有密码的
cd /var/www/html
mkdir mystuff 下载页面 不改名称
vim /etc/httpd/conf/httpd.conf
修改主站目录
AuthType Basic
AuthName "WebAuthen"
AuthliserFile /etc/httpd/conf/htpasswd
Require valid-user 所有用户都可以认证Require valid-user
service httpd restart
吕星昊
2014.6.7
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29475508/viewspace-1177896/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29475508/viewspace-1177896/