荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: suetall.bbs@bjsing.net (机器猫), 信区: Linux
标  题: linux服务器应用-三
发信站: DQPI (Mon Mar 17 18:23:05 2003)
转信站: SZU!news.tiaozhan.com!maily.cic.tsinghua.edu.cn!news.bjsing.net!DQPI

九、FTP服务器:
Rh72自带了wu_ftp,但是由于其毛病不少,所以我们不用它,我们用性能及安全性能均
优于它的proftpd来代替它。
1]下载软件:ftp://ftp.proftpd.org/distrib/source/proftpd-1.2.5.tar.gz
2]安装:
tar zxvf proftpd-1.2.5.tar.gz
cd proftpd-1.2.5
./configure –prefix=/usr/local/proftpd //指定安装在/usr/local/proftpd目录下

make
make install
cp contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd
chmod 700 /etc/rc.d/init.d/proftpd
chkconfig –level 3 proftpd on //设置为系统自启动服务
cp /usr/local/proftpd/sbin/proftpd /usr/sbin //将proftpd拷至/usr/sbin目录下,
让系
统能自动搜索到,也免得再去加一个搜索路径
3]配置/usr/local/proftpd/etc/proftpd.conf文件:
vi /usr/local/proftpd.conf
ServerName "Xchen FTP server" //服务器登录提示
ServerType standalone
DefaultServer on
Port 21
Umask 022
MaxInstances 30
User nobody
Group nobody //原来为nogroup,请改成nobody
RequireValidShell off //手动添加此名,重要
//限定test组用户只能访问自己的home目录,而不能向上浏览
DefaultRoot ~ test
//限定test组用户只能访问自己的/home/ftp目录,不能向上浏览
DefaultRoot ~/ftp test
//限定music组用户只能访问/home/music目录,不能向上浏览
DefaultRoot /home/ftp music
//除music组中bb用户外都能访问/home/music目录,不能向上浏览
DefaultRoot /home/ftp music,!bb
//上面组需要自己建立:groupadd test,gpasswd –a username test
ServerIdent off //登录时不显示版本信息
<Directory /*>
AllowOverwrite on
</Directory>
<Anonymous /home/ftp> // /home/ftp为匿名用户登录目录
User ftp
Group ftp
UserAlias anonymous ftp
MaxClients 10
DisplayLogin welcome.msg
DisplayFirstChdir .message
<Limit WRITE>
DenyAll
</Limit>
</Anonymous>
4]启动服务:/etc/rc.d/init.d/proftpd start
5]测试,在客户端用FTP软件或命令行FTP程序进行访问ftp.cx.com。
6]proftpd技岂只此,还有很多高级应用,请参考相关资料,这里就不多赘述。
十、WWW服务
www服务用apache来实现,步骤极其简单,当然,这里说的是初级应用。因为我们要实现
的是简单的www服务,所以只需更改下面几个参数即可:
1]Vi /etc/httpd/conf/httpd.conf
ServerName http://www.cx.com/
DocumentRoot ”/var/www”
2]拷贝网页文件到/var/www目录
3]启动服务:/etc/rc.d/init.d/httpd start
将httpd设置为系统自启动服务:chkconfig –level 3 httpd on
4]测试:在ie中用http://www.cx.com/测试。
为什么把www服务讲得这么简单呢,主要是因为这种单一类型的网页文件服务用得较少,
现在大多数都要用cgi,asp,php,还有数据库等,关于这方面配置还请参考相关资料,这
里不作详解。
十一、动态域名服务
动态域名这个叫法不大妥当,应该叫动态ip for 域名才对。到现在为止,ftp和www服务
我们都实现了,在局域网内可以用http://www.cx.com/来访问,但是我们已经用ADSL连
通了internet,我们怎样让外部访问我们的ftp,www服务器呢,总不成每都通知对方服务
器的IP吧,所以就要用到动态域名服务,大致原理是每次ADSL拔号时将自身IP更新到外
部DNS服务器数据库中所对应的那个域名,所以我们每次访问这个域名就可以了,在这里
讨论一下http://www.3322.org/提供的动态服务的实现。
1]登录http://www.3322.org/网站,注册一个用户,并申请一个动态域名xxxx.3322.or
g。
2]下载linux客户端软件:
http://www.3322.org/dyndnspage/ez-ipupdate-3.0.10-linux-i386.tgz
3]安装软件:
tar zxvf ez-ipupdate-3.0.10-linux-i386.tgz
mv ez-ipupdate-3.0.10-linux-i386 /usr/local/ezip
4]编辑/usr/local/ezip/qdns.conf文件:
vi /usr/local/qdns.conf
service-type=qdns
user=username:password //用户名及密码,用冒号隔开
host=xxxxx.3322.org //你申请的域名
interface=ppp0 //接口为ppp0
max-interval=2073600
cache-file=/tmp/ez-ipupdate.cache
5]将当前ip现新到我们申请的域名:
cd /usr/local/ezip
ez-ipupdate –c qdns.conf
系统会提示数据更新成功,好,我们来ping一下xxxx.3322.org,哈,果然是ppp0
的IP,再用http://xxx.3322.org/试一下,一切OK,爽。
6]问题又来了,难道我们每次启动ADSL都要用手动更新一次吗,你可能会想到用cronta
b让它每隔几分钟更新一次,建议不错,不过为了ip更新而启用crond服务
似乎有点小题大做,我的方法,修改/usr/sbin/adsl-start脚本:
vi /usr/sbin/adsl-start
找到倒数25行”tty –s && $ECHO “ Connected ! “,在其下增加一行:
/usr/local/ezip/ez-ipupdate –c /usr/local/ezip/qdns.conf
存盘退出,OK,我们让ADSL拔号完成以后自动更新,爽吧!
7]测试一下:
adsl-start
. Connected!
ez-ipupdate Version 3.0.10
Copyright (C) 1999-2000 Angus Mackay.
connected to members.3322.org (202.108.36.139) on port 80.
request successful
OK,数据更新成功。
好,现在你随时随地都可以用xxxx.3322.org访问你的服务了,不错吧。
十二、openssh的设置
如果你在家里或者其它地方,怎样控制你的服务器,你可能会想到用telnet,本来是可
以的,但是由于telnet用的是明码传输,容易给那些不怀好意者可乘之机,所以我们用
openssh来代替telnet。
1]卸载原来的2.9x版,2.9x版有bug,不安全:
rpm –e openssh
2]最新软件包下载:
ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-3.4p1.tar.gz
3]安装软件:
tar zxvf openssh-3.4p1.tar.gz
cd openssh-3.41
./configure --prefix=/usr/local/ssh \
--sysconfdir=/etc/ssh \
--with-tcp-wrappers \
--with-ipv4-default \
--with-md5-passwords
make
make install
注:安装完成以后,会自动生成主机密钥,还会提示需要sshd用户帐号,可用useradd加
一个sshd用户。
install /contrib/redhat/sshd.pam /etc/pam.d/sshd
cp contrib/redhat/sshd.init /etc/rc.d/init.d/sshd
chkconfig --level 3 sshd on ;配置成系统服务
4]配置openssh之/etc/ssh/ssh_config文件
vi /etc/ssh/ssh_config
Host *
ForwardAgent no
ForwardX11 no
RhostsAuthentication no
RhostsRSAAuthentication no
RSAAuthentication yes
PasswordAuthentication yes
BatchMode no
CheckHostIP yes
StrictHostKeyChecking ask
IdentityFile ~/.ssh/identity
Port 22
Cipher 3des
EscapeChar ~
5]配置openssh之/etc/ssh/sshd_config文件
vi /etc/ssh/sshd_config
Port 22
ListenAddress 0.0.0.0
ListenAddress ::
HostKey /etc/ssh/ssh_host_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
KeyRegenerationInterval 3600
ServerKeyBits 768
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 600
#PermitRootLogin yes #还是不要让root直接登录为妙!
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
RhostsAuthentication no
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
IgnoreUserKnownHosts no
PasswordAuthentication yes
PermitEmptyPasswords no
Subsystem sftp /usr/local/ssh/libexec/sftp-server
6]配置用户的加密密钥
useradd test
passwd test
su test
ssh-keygen -d
出现提示请回车并输入passwd,再次输入passwd。
注:这个密码是系统加密运算时用到的,登录时还用原来密码。
7]启动服务
/etc/rc.d/init.d/sshd start
8]在客户端用test帐号进行测试。
乱七八糟写了一大篇,也该收尾了,冰冻三尺非一日之寒,要多练多问多看多写,前进
吧,朋友!

--
                   ★★★★★  BM: SUETALL   ★★★★★
                   ★★★★★  WELLCOME TO   ★★★★★
                   ★★★★★     SPE        ★★★★★
                   ★★★★★ 这里不分系别! ★★★★★

※ 来源:·北极星BBS站 bjsing.net·[FROM: 10.1.146.249]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店