Linux/ANSI C/C++/Perl/Python
自由的心,永远飞翔...

2006年9月3日

 默认的ls 显示目录颜色为蓝色,在暗背景下难以看清。现介绍将目录颜色改为浅兰的方法:

将/etc/DIR_COLORS文件cp到~/下,并改名为.dir_colors,搜索DIR,将其改为01;36(原来为01;34),重新打开term即可。


1# Configuration file for the color ls utility
2# This file goes in the /etc directory, and must be world readable.
3# You can copy this file to .dir_colors in your $HOME directory to override
4# the system defaults.
5
6# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
7# pipes. 'all' adds color characters to all output. 'none' shuts colorization
8# off.
9 COLOR tty
10
11# Extra command line options for ls go here.
12# Basically these ones are:
13# -F = show '/' for dirs, '*' for executables, etc.
14# -T 0 = don't trust tab spacing when formatting ls output.
15 OPTIONS -F -T 0
16
17# Below, there should be one TERM entry for each termtype that is colorizable
18TERM linux
19TERM console
20TERM con132x25
21TERM con132x30
22TERM con132x43
23TERM con132x60
24TERM con80x25
25TERM con80x28
26TERM con80x30
27TERM con80x43
28TERM con80x50
29TERM con80x60
30TERM cons25
31TERM xterm
32TERM rxvt
33TERM xterm-color
34TERM color-xterm
35TERM vt100
36TERM dtterm
37TERM color_xterm
38TERM ansi
39TERM screen
40TERM screen.linux
41TERM kon
42TERM kterm
43TERM gnome
44TERM konsole
45
46# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
47 EIGHTBIT 1
48
49# Below are the color init strings for the basic file types. A color init
50# string consists of one or more of the following numeric codes:
51# Attribute codes:
52# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
53# Text color codes:
54# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
55# Background color codes:
56# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
57NORMAL00# global default, although everything should be something.
58FILE00# normal file
59DIR 01;36 # directory
60LINK 01;36 # symbolic link
61FIFO 40;33 # pipe
62SOCK 01;35 # socket
63BLK 40;33;01 # block device driver
64CHR 40;33;01 # character device driver
65ORPHAN 01;05;37;41 # orphaned syminks
66MISSING 01;05;37;41 # ... and the files they point to
67
68# This is for files with execute permission:
69EXEC 01;32
70
71# List any file extensions like '.gz' or '.tar' that you would like ls
72# to colorize below. Put the extension, a space, and the color init string.
73# (and any comments you want to add after a '#')
74.cmd 01;32 # executables (bright green)
75.exe 01;32
76.com 01;32
77.btm 01;32
78.bat 01;32
79.sh 01;32
80.csh 01;32
81.tar 01;31 # archives or compressed (bright red)
82.tgz 01;31
83.arj 01;31
84.taz 01;31
85.lzh 01;31
86.zip 01;31
87.z 01;31
88.Z 01;31
89.gz 01;31
90.bz2 01;31
91.bz 01;31
92.tz 01;31
93.rpm 01;31
94.cpio 01;31
95.jpg 01;35 # image formats
96.gif 01;35
97.bmp 01;35
98.xbm 01;35
99.xpm 01;35
100.png 01;35
101.tif 01;35



posted @ 2006-09-03 14:05 我心飞翔 阅读(2469) | 评论 (140)编辑 收藏

2006年8月20日

ProFTPd

From Luna's Wiki

目錄 [隱藏]

所需套件

proftpd


在安裝 ProFTPd 時,請依您的需求來選擇 ProFTPd 的運行方式。

註:

您可以隨時使用 dpkg-reconfigure --priority=low proftpd 來重新設定這些選項

在安裝過程中要設定 ProFTPd 的啟動方式:使用 StandAlone(永遠啟動)或是使用 inetd(由 inetd 來管理)。

建議使用 StandAlone,因為 ProFTPd 使用 StandAlone 的方式啟動時,可以加入避免 DoS 攻擊的選項。

ProFTPd configuration
ProFTPd can be run either as a service from inetd, or as a standalone server. Eeach choice has its own benefits.

If you have only a few ftp connections per day, it may not be worth the resources to keep proftpd running at all times.

On the other hand, if your ftp site is visited frequently, inetd is not a good choice, because each time a connection is opened, a new process is spawned.

Run proftpd from inetd or standalone?

inetd
standalone

<OK>

建議安裝套件

簡介

一般設定

設定登入的目錄

設定除了特定帳號之外,其它皆以 /home/ftp 為預設的登入路徑。

不過這樣也同時限制了使用使只能在該目錄中活動。

DefaultRoot /home/ftp !UserName

設定除了特定帳號之外,其它皆以 Home Directory 為預設的登入路徑

DefaultRoot ~ !UserName

讓登入的使用者限制在某一特定目錄

限制使用者只能在 Home Directory 中活動:

...
<VirtualHost myhost.mynet.foo>
DefaultRoot ~
...
</VirtualHost>

限制 users 群組成員使用者只能在 /u2/public 中活動。但是同時是 staff 群組成員則不在此限:

...
<VirtualHost myhost.mynet.foo>
DefaultRoot /u2/public users,!staff
...
</VirtualHost>

設定 ProFTPd 只監聽特定的網路介面

設定 ProFTPd 不要使用 GMT

註:

如果您的 FTP 上面的時間日期不太對的話,大部份就是這個原因了
TimesGMT off

設定 root 也可以 Logon(非常不建議!)

RootLogin on

設定除了 incoming 目錄之外,匿名用的目錄及其子目錄都無法寫入

在 incoming 目錄中所上傳的檔案的權限為 UserName.UserGroup, 讓使用者可以上傳卻無法下載。 如果把 <Limit STOR> 替代成 <Limit WRITE> 的話, 使用者可以進行刪除、更名、建立子目錄等動作:

<Anonymous /home/ftp>
# All files uploaded are set to username.usergroup ownership
User username
Group usergroup
UserAlias ftp username
AuthAliasOnly on
RequireValidShell off

<Directory pub/incoming/>
<Limit STOR CWD>
AllowAll
</Limit>
<Limit READ RMD DELE MKD>
DenyAll
</Limit>
</Directory>
</Anonymous>

對匿名的使用者隱藏某個目錄

在這裡是將特定的 使用者 / 群組 的目錄隱藏起來 但是在這裡的特定的使用者/群組不能是 Anonymous 所使用的使用者/群組。

<Anonymous ~ftp>
...
<Directory Private>
HideGroup UserGroup
HideUser UserName
</Directory>
...
</Anonymous>

隱藏某個目錄

IgnoreHidden

建立虛擬的 FTP Server

<VirtualHost 10.0.0.1>
ServerName "My virtual FTP server"
</VirtualHost>

只讓 Anonymous 的使用者登入虛擬的 FTP Server

<VirtualHost 10.0.0.1>
ServerName "My virtual FTP server"
<Limit LOGIN>
DenyAll
</Limit>
<Anonymous /usr/local/private>
User private
Group private
<Limit LOGIN>
AllowAll
</Limit>
...
</Anonymous>
</VirtualHost>

<LOGIN> 的功用

<LOGIN> 通常會出現在 Server Config、<VirtualHost>、<Anonymous> 及 <Directory> 這些段落裡。 <LOGIN> 是用來控管 Client 是否可以進行連線。 注意:寫在較後面的設定會『蓋過』較前的設定。

如下,禁止所有來自 10.1.1.x 的連線(沒有任何警告訊息即切斷所有連線):

...
<Limit LOGIN>
Order deny,allow
Deny from 10.1.1.
Allow from all
</Limit>
...

如下,除了 anonymous 之外全都禁止連線,但是會出現 "Login invalid" 訊息:

...
<Limit LOGIN>
DenyAll
</Limit>
<Anonymous ~ftp>
...
<Limit LOGIN>
AllowAll
</Limit>
...

讓使用者建立自己的匿名目錄

頻寬控管

TransferRate

RateReadBPS 81920
RateReadFreeBytes 5120
RateReadHardBPS on

限制上傳的檔案大小

MaxRetrieveFileSize
MaxStoreFileSize

限制使用者帳號同時連線上限

MaxClientsPerUser

支援斷點續傳

AllowRetrieveRestart

限制 IP 的同時連線上限

MaxClientsPerHost       1

修改連線時所顯示的 Daemon 名稱及版本

ServerIdent  On "Linux.co.uk server"

ServerIdent off

在 Login 之前顯示歡迎訊息

DisplayConnect  /etc/proftp.msg

在 Login 之後顯示歡迎訊息

DisplayLogin    /etc/proftp.msg

成功認證後的歡迎訊息

AccessGrantMsg "Guest access granted for %u."

錯誤訊息 "No certificates found!"?

請參閱 http://www.linuxdoc.org/HOWTO/SSL-Certificates-HOWTO/

openssl req -new -x509 -days 365 -nodes -out ftpd-rsa.pem -keyout ftpd-rsa-key.pem cp *.pem /etc/ssl/certs/

使用 PAM 來進行認證

設定 Log 檔案位置

SystemLog

設定磁碟配額

Quotas                  on      # 使用 Quota
QuotaCalc on # 當 .quota 不存在時是否即時計算出已使用 Quota 的大小
QuotaType soft # 如果設定為 hard,將會把超過 Quota 的檔案刪掉
DefaultQuota 8000 # Quota 的大小
QuotaBlockSize 1024 # Quota 的計算單位
QuotaBlockName kb # Quota 顯示時所使用的單位

設定顯示隱藏檔

ShowDotFiles on

最高重試次數

MaxLoginAttempts 3

注意事項

參考資訊

常見問題解答

posted @ 2006-08-20 19:05 我心飞翔 阅读(835) | 评论 (0)编辑 收藏
 
Q:在那里可以找到最新版本?
A:请您查看www.proftpd.org

Q:如何启动或停止proftpd?
A:请您使用命令which proftpd,找到文件的位置,假设(通常)为/usr/sbin/proftpd
启动/usr/sbin/proftpd start
停止/usr/sbin/proftpd stop

Q:proftpd如何设置为系统启动
A:请您拷贝原编译目录proftpd-1.2.xxx/contrib/dist/rpm/下的proftpd.init.d文件至/etc/rc.d/init.d/下

,更名为proftpd,
cp /contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd
chmod 700 proftpd
chkconfig --level 3 proftpd on

Q:welcome.msg与.message有什么别
A:请您看proftpd.conf中的描述
DisplayLogin welcome.msg
DisplayFirstChdir .message
也就是说welcome.msg在登陆时显示,而.message在每次更改目录时显示

Q:在本机上能登录proftpd,在局域网和其他地方不行,why?
A:请您降低您的防火墙设置,使用setup进行设置

Q:如何限定每个ip的最大连接数(匿名)?
A: 请您参看Configuration.html,默认值如下
#MaxClientsPerHost none

Q:安装proftpd时,出现类似“configure: error: no acceptable cc found in $PATH”,怎么办?
A:请您安装GCC编译器及其依赖软件包

Q:如何限制用户上载和下载的速率?
A:请您使用以下参数
RateReadBPS RateReadFreeBytes
RateWriteBPS RateWriteFreeBytes
RateReadBPS和RateWriteBPS限制下载和上载的速率
RateReadFreeBytes和RateWriteFreeBytes限制当用户现在这么多数据量以后再进行限速,这样可以实现对于

小文件不限速,而大文件限速。

Q:如何设置空闲超时时间?
A:请您检查
TimeoutIdle 设置空闲连接超时时间
TimeoutLogin 设置空闲登陆超时时间
TimeoutNoTransfer 设置当没有数据传输时的超时时间
TimeoutStalled 设置被阻塞的下载的超时时间

Q:proftp无法inetd启动?
A:请您试试xinetd

Q:如何禁止admin用户登录自己的home目录?
A:请您在proftpd.conf中使用DefaultRoot ~ !admin

Q:达到最大用户数限制时,如何给出提示信息?
A:请您在proftpd.conf中使用MaxHostsPerUser 100 "对不起,已经到达该用户最大连接数100,请您稍候再试!"

Q:怎么限制每个IP允许的线程数?
A:请您在proftpd.conf中使用MaxClientsPerHost 1 "对不起,每个ip只允许有1个连接!"

Q:安装后找不到proftpd.conf?
A:请您检查是否安装proftpd-inetd-1.2.*-1.i386.rpm或者proftpd-standalone-1.2.*-1.i386.rpm,其中*为

您的具体的版本号

Q:如何查看proftpd的运行信息或者进行调试?
A:请您使用命令/usr/local/sbin/proftpd -d9 -n

Q:普通用户可以登录,但匿名用户无法登录?
A:请您检查proftpd.conf,修改<Anonymous ~ftp>为<Anonymous /home/ftp>(这里/home/ftp可以是任何希望

匿名用户登录以后的当前根目录,但是确保要使该目录允许ftp用户访问),并且若<Anonymous /home/ftp>部

分的User指令指定的用户为ftp用户,则需要在配置文件中添加如下命令指示:
RequireValidShell off,如果还不行,请删除相应帐号,并重新创建用户及其相应的组

Q:如何限制一个正常用户登录以后只能访问某个目录?

A:可以通过指令DefaultRoot来实现。例如若希望将ftpusers组的用户限定在自己的home目录下,则需要首先创

建该组: /usr/sbin/groupadd ftpusers然后将用户ideal加入到该组中: usrmod -G ftpusers ideal 最后在

在proftpd.conf文件中添加如下内容: DefaultRoot ~ ftpusers
也可以限制用户登录以后仅仅访问自己主目录下的一个子目录:
Default! Root ~/anoftp ftpusers
当然也可以将用户限制在其他目录之下,而不是自己的home目录下:
DefaultRoot /tmp ftpusers
也可以限定一个用户组的某些用户被限制,而其他不作限制:
DefaultRoot ~ ftpusers,!empolyee
这个指令指示仅仅限制ftpusers组中的不是empolyee组的用户进行限制。

Q:如何隐藏服务器版本信息,以增强安全性
A:请您在proftpd.conf中添加ServerIdent off

Q:如何设定虚拟主机?
A:您可以通过指令:VirtualHost来实现,一个最简单的例子:
<VirtualHost 192.168.0.1>
ServerName "virtual FTP server"
</VirtualHost>

若您仅仅希望通过匿名访问某个虚拟主机,则使用如下! 的指令:
<VirtualHost 192.168.0.1>
Serv erName "virtual FTP server"
<Limit LOGIN>
DenyAll
</Limit>
<Anonymous /usr/local/private>
User private
Group private
<Limit LOGIN>
AllowAll
</Limit>
</Anonymous>
</VirtualHost>
这样192.168.2.35的这台主机则仅仅允许匿名登录。

Q:为何我配置的proftpd在用flashget的站点资源管理器时总是到list-la这一步时出错,即客户端不能列目录,
但用ie浏览器就可以自由的进入各个目录?
A:端口21是ftp 的command端口,而文件列表和数据则是通过数据端口,例如“正在连接 ftp 数据 socket

61.138.232.37:1120”,估计是防火墙规则的问题,请注意你的防火墙配置是否正确

Q:如何禁止root登录
A:请您在proftpd.conf中添加RootLogin off

Q:如何设置最大尝试次数?
A:请您在proftpd.conf中添加MaxLoginAttempts 3,其中3是你设的数值

Q:在Redhat8.0下装proftpd_1.2.6,每次服务启动完后,登陆的时候总是显示:500 FTP server shut down

(going down at Sat Oct 5 15:59:31 2002) -- please try again later. 这是怎么回事啊?
A:请您删除shutmsg文件,rm -f /etc/shutmsg

Q:怎么把数据连接类型改成PASV?
A:请您在proftpd.conf里添加PassivePorts 49152 65534

Q:在shell下用了ftpshut后,再在shell下用proftpd命令后,总提示ERROR: Syntax error, command

unrecognized.怎么办?
A:请您使用ftprestart

Q:文件在多个分区中,要求在一个ftp目录中出现,如何实现?
A:您可以使用mount --bind命令,把文件都挂接到一个目录,然后再把虚拟路径指向这个目录


Q:装proftpd时,./configure再make,然后它就一直在循环checking文件,why?
A:一般是文件属性检查错误,请您检查文件属性是否正常,如下载时,电脑时间是否正确

Q:我想让匿名用户访问我的windows分区文件夹,请问如何实现?
A:请您在/etc/fstab文件中使fat分区自动mount到anonymous主目录就可以了'

posted @ 2006-08-20 18:51 我心飞翔 阅读(428) | 评论 (0)编辑 收藏

2006年4月16日


刚申请的blog,专注于linux级c++、perl等自由的软件开发。特此纪念
posted @ 2006-04-16 21:23 我心飞翔 阅读(284) | 评论 (0)编辑 收藏
仅列出标题