FreeBSDのススメ telnet・ftpサーバーを起動しちゃおう! FreeBSD4.x系列ではデフォルトでtelnet及びftpサーバーが起動できる 状態になっていましたが、5.x系列ではデフォルトでは起動されません。 まず、デフォルトではどんな状態になるか確認してみましょう。 telnet > telnet localhost <- とりあえず自分のマシン自体にtelnetしてみる Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused telnet: Unable to connect to remote host > ftp > ftp localhost <- とりあえず自分のマシン自体にftpしてみる ftp: connect: Connection refused ftp> bye <- ftpを終了させるためのコマンド > どうでしょう。上記の通りにどちらもサーバーに接続できない状態に なっていますね。これはtelnet・ftpどちらのサーバーも起動していない 状態になっているのが原因です。 -------------------------------------------------------------------------------- 設定手順 設定は以下の手順で行います。 1・ /etc/inetd.confの設定 2・ /etc/rc.confの設定 3・ 再起動 4・ 接続の確認 これだけです。では早速設定していきましょう。 -------------------------------------------------------------------------------- 1. /etc/inetd.confの設定 端末からのtelnetやftp接続要求に対して、FreeBSDは次のような手順を とります。 端末からの接続要求 ↓ inetdが受け付け ↓ 要求されたサービス(telnetやftp)に対するサーバーの起動 ↓ サーバーアプリケーションの起動 ↓ 接続成立 /etc/inetd.confは上記の赤の 部分で起動できるサーバーを決定する設定ファイルです。 では早速設定しましょう。 まずは、スーパーユーザーになって、/etc/inetd.confの設定を行います。 > su Password: <-rootのパスワードを入力 # cd /etc # vi inetd.conf /etc/inetd.confの内容 # $FreeBSD: src/etc/inetd.conf,v 1.61 2002/11/12 17:31:11 obrien Exp $ # # Internet server configuration database # # Define *both* IPv4 and IPv6 entries for dual-stack support. # To disable a service, comment it out by prefixing the line with '#'. # To enable a service, remove the '#' at the beginning of the line. # #ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l #ftp stream tcp6 nowait root /usr/libexec/ftpd ftpd -l #telnet stream tcp nowait root /usr/libexec/telnetd telnetd #telnet stream tcp6 nowait root /usr/libexec/telnetd telnetd #shell stream tcp nowait root /usr/libexec/rshd rshd #shell stream tcp6 nowait root /usr/libexec/rshd rshd #login stream tcp nowait root /usr/libexec/rlogind rlogind #login stream tcp6 nowait root /usr/libexec/rlogind rlogind #finger stream tcp nowait/3/10 nobody /usr/libexec/fingerd fingerd -s …以下省略… 上記の赤い部分の「#」マークを 消してください。 以上で、/etc/inetd.confの設定は終了です。telnetやftpに 限らず、他のサーバーも起動させたい場合は起動させたいサーバーが 記述されている行の先頭の「#」マークを同様に削除すればOKです。 -------------------------------------------------------------------------------- 2. /etc/rc.confの設定 端末の接続要求にをまず最初に受け付ける「inetd」が起動して いないと、どう頑張っても接続できません。inetdがFreeBSDの 起動時に稼働するように設定する必要があります。この設定の ファイルが/etc/rc.confです。では早速設定しましょう。 先程スーパーユーザーになっていますので、そのまま管理者権限で 作業します(ログアウトしてしまった人は再度rootでログインしてください。) # cd /etc # vi rc.conf /etc/rc.confの内容 # -- sysinstall generated deltas -- # Sat Nov 8 19:40:52 2003 # Created: Sat Nov 8 19:40:52 2003 # Enable network daemons for user convenience. # Please make all changes to this file, not to /etc/defaults/rc.conf. # This file now contains just the overrides from /etc/defaults/rc.conf. kern_securelevel_enable="NO" keymap="jp.106" linux_enable="YES" moused_enable="YES" sendmail_enable="YES" sshd_enable="YES" usbd_enable="YES" inetd_enable="YES" お使いの環境によっても異なりますが、だいたいこんな感じのファイル です。 上記の赤い部分の一行を追加してください。 以上でrc.confの設定は終了です。 -------------------------------------------------------------------------------- 3. 再起動 あとは、コンピューターを再起動するだけです。 # cd /etc # reboot -------------------------------------------------------------------------------- 4. 接続の確認 コンピューターが起動してログインしたら早速接続テストをしてみましょう telnet > telnet localhost <- とりあえず自分のマシン自体にtelnetしてみる Trying 127.0.0.1... Connected to localhost.xxx.com. Escape character is '^]'. Trying SRA secure login: User (hornets): hornets <-ログイン名の入力 Password: <-パスワードの入力 [ SRA accepts you ] FreeBSD/i386 (xxx.com) (ttyp3) Last login: Fri Nov 14 21:23:30 from localhost Copyright (c) 1992-2003 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD 5.1-RELEASE (GENERIC) #0: Tue Nov 11 23:00:35 JST 2003 Welcome to FreeBSD! Before seeking technical support, please use the following resources: o Security advisories and updated errata information for all releases are at http://www.FreeBSD.org/releases/ - always consult the ERRATA section for your release first as it's updated frequently. o The Handbook and FAQ documents are at http://www.FreeBSD.org/ and, along with the mailing lists, can be searched by going to http://www.FreeBSD.org/search/. If the doc distribution has been installed, they're also available formatted in /usr/share/doc. If you still have a question or problem, please take the output of `uname -a', along with any relevant error messages, and email it as a question to the questions@FreeBSD.org mailing list. If you are unfamiliar with FreeBSD's directory layout, please refer to the hier(7) man page. If you are not familiar with man pages, type `man man'. You may also use sysinstall(8) to re-enter the installation and configuration utility. Edit /etc/motd to change this login announcement. > ftp > ftp localhost <- とりあえず自分のマシン自体にftpしてみる Connected to localhost.xxx.com. 220 xxx.com FTP server (Version 6.00LS) ready. Name (localhost:hornets): hornets 331 Password required for yoshihiko. Password: <-パスワードの入力 230 User yoshihiko logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> 無事接続が成功していることが確認できたでしょうか? -------------------------------------------------------------------------------- 最後に 以外と簡単な設定で接続できるようになりましたね。 telnet や ftpは稼働させるだけでは危険ですので、必ず 「アクセス制限をかけよう!」 で説明したアクセス制限の設定を行ってください。