分类:
2010-11-03 17:49:43
环境:AIX 5.2或更高
解答: 当我们想要将一个目录设置为ftp只读或ftp只写时,我们可以借助/etc/ftpaccess.ctl文件来实现这种权限控制。
一、设置一个目录为ftp只读
1. 编辑/etc/ftpaccess.ctl,加入如下一行:
readonly: /test
2. ftp连接服务器进行读取传输,成功
HA_node2@/> ftp 172.16.18.13
Connected to 172.16.18.13.
220 DumpServer FTP server (Version 4.2 Fri Feb 3 22:13:23 CST 2006) ready.
Name (172.16.18.13:root): root
331 Password required for root.
Password:
230-Last unsuccessful login: Tue May 13 08:44:37 2008 on /dev/pts/1 from 9.181.50.139
230-Last login: Tue May 13 10:45:06 2008 on ftp from ::ffff:9.181.50.246
230 User root logged in.
ftp> cd /test
250 CWD command successful.
ftp> lcd /test
Local directory now /test
ftp> dir
200 PORT command successful.
150 Opening data connection for /bin/ls.
total 29472
-rw-r--r-- 1 root system 7539356 Apr 24 19:42 trace.r
-rw-rw-rw- 1 root system 880640 Apr 24 19:41 trace.raw
-rw-rw-rw- 1 root system 1158232 Apr 24 19:41 trace.raw-0
-rw-rw-rw- 1 root system 1059928 Apr 24 19:41 trace.raw-2
-rw-rw-rw- 1 root system 1050952 Apr 24 19:41 trace.raw-3
-rw-rw-rw- 1 root system 1195440 Apr 24 19:41 trace.raw-4
-rw-rw-rw- 1 root system 2196288 Apr 24 19:41 trace.raw-5
226 Transfer complete.
ftp> bin
200 Type set to I.
ftp> get trace.raw
200 PORT command successful.
150 Opening data connection for trace.raw (880640 bytes).
226 Transfer complete.
880852 bytes received in 0.08342 seconds (1.031e+04 Kbytes/s)
local: trace.raw remote: trace.raw
3.进行写入传输,则遭遇报错
ftp> bin
200 Type set to I.
ftp> put trace.raw-1
200 PORT command successful.
550 Write access denied
二、设置一个目录为ftp只写
1. 编辑/etc/ftpaccess.ctl,加入如下一行:
writeonly: /test
2. ftp连接服务器进行读取传输,则遭遇报错
HA_node2@/> ftp 172.16.18.13
Connected to 172.16.18.13.
220 DumpServer FTP server (Version 4.2 Fri Feb 3 22:13:23 CST 2006) ready.
Name (172.16.18.13:root): root
331 Password required for root.
Password:
230-Last unsuccessful login: Tue May 13 08:44:37 2008 on /dev/pts/1 from 9.181.50.139
230-Last login: Tue May 13 15:45:37 2008 on ftp from ::ffff:172.16.18.11
230 User root logged in.
ftp> cd /test
250 CWD command successful.
ftp> lcd /test
Local directory now /test
ftp> dir
200 PORT command successful.
150 Opening data connection for /bin/ls.
total 29472
-rw-r--r-- 1 root system 7539356 Apr 24 19:42 trace.r
-rw-rw-rw- 1 root system 880640 Apr 24 19:41 trace.raw
-rw-rw-rw- 1 root system 1158232 Apr 24 19:41 trace.raw-0
-rw-rw-rw- 1 root system 1059928 Apr 24 19:41 trace.raw-2
-rw-rw-rw- 1 root system 1050952 Apr 24 19:41 trace.raw-3
-rw-rw-rw- 1 root system 1195440 Apr 24 19:41 trace.raw-4
-rw-rw-rw- 1 root system 2196288 Apr 24 19:41 trace.raw-5
226 Transfer complete.
ftp> bin
200 Type set to I.
ftp> get trace.raw-2
200 PORT command successful.
550 Read access denied
3.进行写入传输,成功
ftp> bin
200 Type set to I.
ftp> put trace.raw-1
200 PORT command successful.
150 Opening data connection for trace.raw-1.
226 Transfer complete.
880640 bytes sent in 0.07938 seconds (1.083e+04 Kbytes/s)
local: trace.raw-1 remote: trace.raw-1
ftp> dir
200 PORT command successful.
150 Opening data connection for /bin/ls.
total 31192
-rw-r--r-- 1 root system 7539356 Apr 24 19:42 trace.r
-rw-rw-rw- 1 root system 880640 Apr 24 19:41 trace.raw
-rw-rw-rw- 1 root system 1158232 Apr 24 19:41 trace.raw-0
-rw-r----- 1 root system 880640 May 13 15:53 trace.raw-1
-rw-rw-rw- 1 root system 1059928 Apr 24 19:41 trace.raw-2
-rw-rw-rw- 1 root system 1050952 Apr 24 19:41 trace.raw-3
-rw-rw-rw- 1 root system 1195440 Apr 24 19:41 trace.raw-4
-rw-rw-rw- 1 root system 2196288 Apr 24 19:41 trace.raw-5
226 Transfer complete.
chinaunix网友2010-11-05 08:50:29
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com