カスタム検索
このエントリーをはてなブックマークに追加
tomo.gif (1144 ツバツイツト)line.gif (927 ツバツイツト)To previous pageTo home pageMailing to me

wu-ftpd (FTPサーバ) の小技

Modified: 11 November 2002

Redhat Linux 7.3 で実験中です。


ログインディレクトリを仮想ルートにする方法 (2 June 2001)

FTPログインできないユーザを登録したい 
サービスを許可するホストを特定したい (11 November 2002)
anonymous FTPを禁止する方法

ftpでログインしている人を見る方法
Anonymousログインの記録を見る
anonymous のみのサーバーにする方法
家庭内のみログインを有効にする方法

ログインできるがコマンドが使えない


ログインディレクトリを仮想ルートにする方法

FTPでログインすると、そこからディレクトリをさかのぼって、他のユーザのファイルをのぞくことが出来ます。

特別な設定をすると、ログインしたディレクトリの上位のディレクトリには移れないように設定できます。

"/etc/ftpaccess"に、グループを追加

"/etc/ftpaccess"の最後の行として、以下を追加します。

guestgroup   ftpolny

"/etc/group"に、"ftpolny"を追加する

"/etc/group"に、"ftpolny"を追加します。

# groupadd  ftponly

"ftponly"グループのユーザを作る

以下のように、ftponly に所属するグループとして、ユーザ(以下の例では、"tomo")を作成します。

# useradd -g ftponly -G ftponly -d /home/tomo tomo

パスワードの設定

# passwd tomo


tomoでログインすると、そのディレクトリより上位のディレクトリには移動できなくなります。


FTPログインできないユーザを登録したい

/etc/ftpusers に、拒否したいユーザ名を書けば、FTPログインできなくなります。

root でログインできないのは、ここに、root が記載されているからです。


サービスを許可するホストを特定したい

ftpは、"xinetd"というサーバーの一つとして動作していますので、サービスを指定するホストは、"/etc/xinetd.d/wu-ftp"で指定します。

192.168.0.1と、192.168.0.2のみ許可しています。

# default: on
# description: The wu-ftpd FTP server serves FTP connections. It uses \
# normal, unencrypted usernames and passwords for authentication.
service ftp
{
  log_on_success += DURATION
  socket_type = stream
  user = root
  server = /usr/sbin/in.ftpd
  server_args = -l -a
  wait = no
  nice = 10
  only_from = 192.168.0.1 192.168.0.2
}

ただ、この方法は、ftpだけでなく、xinetdで動作しているサービス全部に適用されます。ftpにだけ有効な設定をするには、"/etc/ftphosts"で指定します。

ユーザが、"tomo"で、"192.168.0.0"から"192.168.0.255"までのIPアドレスからのftpを許可しています。

# Example host access file
#
# Everything after a '#' is treated as comment,
# empty lines are ignored

allow tomo 192.168.0.0/24

deny * *

anonymous FTPを禁止する方法

"/etc/ftpaccess"の設定を変更します。

デフォルトでは、以下のように、ログインできます。

C:\WINDOWS>ftp linuxserver
Connected to linuxserver.tomo.lint.ne.jp.
220 linuxserver FTP server (Version wu-2.6.0(1) Mon Feb 28 10:30:36 EST 2000) re
ady.
User (linuxserver.tomo.lint.ne.jp:(none)): anonymous
331 Guest login ok, send your complete e-mail address as password.
Password: xxx@xxx.xxx
230 Guest login ok, access restrictions apply.
ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
total 16
d--x--x--x 2 root root 4096 Aug 13 16:10 bin
d--x--x--x 2 root root 4096 Aug 13 16:10 etc
drwxr-xr-x 2 root root 4096 Aug 13 16:10 lib
drwxr-sr-x 2 root ftp 4096 Feb 4 2000 pub
226 Transfer complete.
ftp: 250 bytes received in 0.44Seconds 0.57Kbytes/sec.
ftp>

インストール後cは、以下のようになっています。

class all real,guest,anonymous *

以下のように、"anonymous" を削除すると、禁止できます。

class all real,guest *

anonymous のみのサーバーにする方法

インストール後"/etc/ftpaccess"は、以下のようになっています。

class all real,guest,anonymous *

以下のように、"anonymous" を削除すると、禁止できます。

class anonclass anonymous *

家庭内のみログインを有効にする方法

インストール後"/etc/ftpaccess"は、以下のようになっています。

class all real,guest,anonymous *

以下のように、"anonymous" を削除すると、禁止できます。

class locanlan real 192.168.0. *

ftpでログインしている人を見る方法

# ftpwho
Service class all:
23029 ? S 0:00 ftpd: p63600e.tomo.lint.ne.jp: anonymous/tomo@tomo.ac
- 1 users (no maximum)
#

Anonymousログインの記録を見る

"/var/log/message" に記録されています。

ユーザー(tomo)やパスワード(tomo@tomo.ac)も記録されています。

  :
Sep 3 11:03:17 linuxserver ftpd[23027]: FTP LOGIN FROM p63600e.tomo.lint.ne.jp [192.168.0.9], tomo
Sep 3 11:03:22 linuxserver ftpd[23027]: FTP session closed
Sep 3 02:03:47 linuxserver ftpd[23029]: ANONYMOUS FTP LOGIN FROM p63600e.tomo.lint.ne.jp [192.168.0.9], tomo@tomo.ac
  :


info.gif (1284 ツバツイツト) 転送バイト数は、"/var/log/xferlog" に記録されているそうです。


ログインできるがコマンドが使えない

エラーを調べたら、

/etc/ftpusers が見つからない

という理由で、拒否されていました。

/etc/ftpusers に、以下の記述をしたらうまくいくようになりました。

root
uucp
news

この /etc/ftpusers には、FTPアクセスを拒否するユーザー名を書くそうです。


To previous pageTo home pageMailing to meJump to Top of pagetomo.gif (1144 ツバツイツト)
カスタム検索



このエントリーをはてなブックマークに追加