FreeBSD 4.8 + OS 付属の ftpd で Anonymous ftp
はじめに
FreeBSD をインストールすると標準でインストールされるOS付属の ftpd で、Anonymous ftp サーバを作ってみます。
と言っても、/stand/sysinstall で追加すると、ちょ〜簡単なんだよね。
ftpサーバっていうと、wu-ftpd と ProFTPD が有名。
/stand/sysinstallでAnonymouse FTPを追加
/stand/sysinstall を使って、ちょ〜簡単に Anonymous FTP を作ってみます。
mico# /stand/sysinstall
Configure → Networking → Anon FTP を選択すると、以下のような画面になります。
lqqqqqqqqqqqqqqqqqqqqqqqq Anonymous FTP Configuration qqqqqqqqqk
x x
x UID: Group: Comment: x
x lqqqqqqk lqqqqqqqqqqqqqk lqqqqqqqqqqqqqqqqqqqqqqk x
x x14 x xoperator x xAnonymous FTP Admin x x
x mqqqqqqj mqqqqqqqqqqqqqj mqqqqqqqqqqqqqqqqqqqqqqj x
x x
x lqqqqqqqqqqqqq Path Configuration qqqqqqqqqqqqk x
x x x x
x x FTP Root Directory: x x
x x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x x
x x x/var/ftp x x x
x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj x x
x x x x
x x Upload Subdirectory: x x
x x lqqqqqqqqqqqqqqqqqqqqk x x
x x xincoming x x x
x mqqqqqqqqqqqmqqqqqqqqqqqqqqqqqqqqjqqqqqqqqqqqqj x
x x
x lqqqqqqk lqqqqqqqqqqk x
x x OK x x CANCEL x x
mqqqqqqqqqqqqqqmqqqqqqjqqqqqqqqqqqqmqqqqqqqqqqjqqqqqqqqqqqqqqqqj
| UID |
ftpというユーザを追加するにあたり、ユーザIDに設定する番号。 |
| Group |
ユーザ ftp が属するグループ名 |
| Comment |
ユーザ ftp のコメント |
| FTP Root Directory |
ユーザ ftp のホームディレクトリ。Anonymousでftpした時、 このディレクトリがルートになります。 |
| Upload Subdirectory |
アップロードが可能なディレクトリ名 |
後は、OKを押して /stand/sysinstall を閉じる。これで終わり。ちょ〜簡単でしょ。
システム上で更新されたのは、ftpというユーザが追加された為、/etc/passwd 関係のファイルと、/var/ftp のディレクトリです。
mico# ls -laR /var/ftp/
total 12
dr-xr-xr-x 6 root operator 512 Oct 18 20:49 .
drwxr-xr-x 22 root wheel 512 Oct 18 20:49 ..
dr-xr-xr-x 2 root operator 512 Oct 18 20:49 bin
dr-xr-xr-x 2 root operator 512 Oct 18 20:49 etc
drwxrwxrwt 2 root operator 512 Oct 18 22:55 incoming
drwxr-xr-x 2 root operator 512 Oct 18 20:49 pub
/var/ftp/bin:
total 510
dr-xr-xr-x 2 root operator 512 Oct 18 20:49 .
dr-xr-xr-x 6 root operator 512 Oct 18 20:49 ..
---x--x--x 1 root operator 189800 Oct 18 20:49 date
---x--x--x 1 root operator 300136 Oct 18 20:49 ls
/var/ftp/etc:
total 10
dr-xr-xr-x 2 root operator 512 Oct 18 20:49 .
dr-xr-xr-x 6 root operator 512 Oct 18 20:49 ..
-rw-r--r-- 1 root operator 45 Oct 18 20:50 ftpmotd
-r--r--r-- 1 root operator 359 Oct 18 20:49 group
-r--r--r-- 1 root operator 531 Oct 18 20:49 passwd
/var/ftp/incoming:
total 4
drwxrwxrwt 2 root operator 512 Oct 18 22:55 .
dr-xr-xr-x 6 root operator 512 Oct 18 20:49 ..
/var/ftp/pub:
total 4
drwxr-xr-x 2 root operator 512 Oct 18 20:49 .
dr-xr-xr-x 6 root operator 512 Oct 18 20:49 ..
動作確認
pub ディレクトリにファイルを置きます。
mico# cd /var/ftp/pub/
mico# ls
mico# echo "hoge" > ./hoge.txt
mico# ls -la
total 6
drwxr-xr-x 2 root operator 512 Oct 19 13:01 .
dr-xr-xr-x 6 root operator 512 Oct 18 20:49 ..
-rw-r--r-- 1 root operator 5 Oct 19 13:01 hoge.txt
mico#
localhost で ftp。ユーザ名は、anonymous 。パスワードはメールアドレス。
> ftp localhost
Connected to localhost.hayagui.com.
220 mico.hayagui.com FTP server (Version 6.00LS) ready.
Name (localhost:kenz): anonymous
331 Guest login ok, send your email address as password.
Password:
230- Your welcome message here.
230- Hello Hayagui.com
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/" is current directory.
ftp> ls
150 Opening ASCII mode data connection for '/bin/ls'.
total 8
dr-xr-xr-x 2 0 operator 512 Oct 18 11:49 bin
dr-xr-xr-x 2 0 operator 512 Oct 18 11:49 etc
drwxrwxrwt 2 0 operator 512 Oct 18 13:55 incoming
drwxr-xr-x 2 0 operator 512 Oct 18 11:49 pub
226 Transfer complete.
先ほどのディレクトリが存在します。最初は pub で、get します。
ftp> cd pub
250 CWD command successful.
ftp> ls
150 Opening ASCII mode data connection for '/bin/ls'.
total 2
-rw-r--r-- 1 0 operator 5 Oct 19 04:01 hoge.txt
226 Transfer complete.
ftp> get hoge.txt
local: hoge.txt remote: hoge.txt
150 Opening BINARY mode data connection for 'hoge.txt' (5 bytes).
100% |**************************************************| 5 00:00 ETA
226 Transfer complete.
5 bytes received in 0.00 seconds (8.40 KB/s)
次に、put できる incoming ディレクトリで put します。
ftp> cd ..
250 CWD command successful.
ftp> cd incoming
250 CWD command successful.
ftp> ls
150 Opening ASCII mode data connection for '/bin/ls'.
226 Transfer complete.
ftp> put hoge.txt
local: hoge.txt remote: hoge.txt
150 Opening BINARY mode data connection for 'hoge.txt'.
100% |**************************************************| 5 00:00 ETA
226 Transfer complete (unique file name:hoge.txt).
5 bytes sent in 0.00 seconds (7.01 KB/s)
ftp> ls
150 Opening ASCII mode data connection for '/bin/ls'.
total 2
-rw-r--r-- 1 14 operator 5 Oct 19 04:04 hoge.txt
226 Transfer complete.
ftp> bye
221 Goodbye.
>
成功。
log
ログをとってみます。
デフォルトでも -l オプションがついているのでログはとるようになっているのですが、
anonymous のログをとるには、-S オプションが必要です。
mico# cat /etc/inetd.conf | grep /ftpd
ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l
#ftp stream tcp6 nowait root /usr/libexec/ftpd ftpd -l
mico#
また、syslog の設定でも log が残るようになっていなし。
mico# cat /etc/syslog.conf
*.err;kern.debug;auth.notice;mail.crit /dev/console
*.notice;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
security.* /var/log/security
auth.info;authpriv.info /var/log/auth.log
mail.info /var/log/maillog
lpr.info /var/log/lpd-errs
cron.* /var/log/cron
*.emerg *
!startslip
*.* /var/log/slip.log
!ppp
*.* /var/log/ppp.log
以下の設定を追加します。
# add ito
ftp.* /var/log/fptd
ログ保存先を作成します。
mico# touch /var/log/ftpd
/etc/inetd.conf を以下のように変更。
ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l -S
で、syslogd と inetd を再起動。
mico# kill -HUP `cat /var/run/syslog.pid `
mico# kill -HUP `cat /var/run/inetd.pid `
さっきと同じように anonymous でログインして hoge.txt を get すると、こんな感じのログが残る。
mico# cat ftpd
Oct 19 14:00:12 2003!kenz@hayagui.com!localhost!/pub/hoge.txt!5!1
mico#
戻る
|