Last Update 2005.03.22 

  •  Fedora Core 3による自宅サーバー構築(CUIベース)
    •  ソフトウエア編(インストール)
      • 私見ですが完璧なセキュリティ設定は存在しないんじゃないか?と思っています。
        ウイルスの定義ファイルが日々更新されるように、ハッカーなどの悪意のある人達も新しい攻撃方法を探しています。
        その攻撃のネタのひとつでもある見つかっていないソフトウエアの脆弱な部分も沢山あるでしょう。
        日々、他のサイトも参考にするなど最新の情報にアンテナを高くして対策を実施して下さい。
        なお、この構築の記録は我が家の環境での記録であり、皆さんの環境で全く同様に再現できる保証はありません。
        留意願います(無保証です)


      • 以上、ftpなどでウイルスを拾って来てしまうなど内部から外部へのアクセスを前提としたセキュリティを意識しています。
        サーバーPCを直接操作してローカル環境での使用を前提としています。


      • 以下、外部から内部(家サーバー)へアクセスが発生します。
        ルーターに穴あけの設定も必要となります。 外部からの不正アクセスを十分意識して作業を進めて下さい。

      •  ftpサーバー(vsftpd)のインストールと設定
        •  vsftpdのインストール -2005年03月22日
          ホームページを作成して公開する時にftpでアップロードしますが、そのサー
          バーをインストールします。
          ソフトなどをftpでダウンロードする事はよくありますが、ここではホームペ
          ージコンテンツをアップロードする目的で使用し、外部からのダウンロードには
          使いません。

          よって明示的に使用を認めたユーザーのみが使用出来る仕様としてセットアップ
          します。

          では、vsftpdをインストールします。
          [root@station ~]# yum -y install vsftpd
          Setting up Install Process
          Setting up Repo:  crash-hat
          repomd.xml                100% |=========================|  951 B    00:00
          Setting up Repo:  base
          repomd.xml                100% |=========================| 1.1 kB    00:00
          Setting up Repo:  updates-released
          repomd.xml                100% |=========================|  951 B    00:00
          Reading repository metadata in from local files
          crash-hat : ################################################## 77/77
          base      : ################################################## 2622/2622
          updates-re: ################################################## 722/722
          Resolving Dependencies
          --> Populating transaction set with selected packages. Please wait.
          ---> Downloading header for vsftpd to pack into transaction set.
          vsftpd-2.0.1-5.i386.rpm   100% |=========================|  12 kB    00:00
          ---> Package vsftpd.i386 0:2.0.1-5 set to be installed
          --> Running transaction check
          
          Dependencies Resolved
          Transaction Listing:
            Install: vsftpd.i386 0:2.0.1-5
          Downloading Packages:
          vsftpd-2.0.1-5.i386.rpm   100% |=========================| 119 kB    00:00
          Running Transaction Test
          Finished Transaction Test
          Transaction Test Succeeded
          Running Transaction
          Installing: vsftpd 100 % done 1/1
          
          Installed: vsftpd.i386 0:2.0.1-5
          Complete!
          [root@station ~]#
          

           設定ファイルの変更 -2005年03月22日
          [root@station ~]# vi /etc/vsftpd/vsftpd.conf
          
          12行目
          anonymous_enable=YES
            匿名ユーザーログイン禁止
          anonymous_enable=NO
          
          81,82行目
          #ascii_upload_enable=YES
          #ascii_download_enable=YES
            アスキーモードでのアップ/ダウンロード許可
          ascii_upload_enable=YES
          ascii_download_enable=YES
          
          85行目
          #ftpd_banner=Welcome to blah FTP service.
            バージョンの非表示化(何も指定しないとバージョンが表示されてしまう)
          ftpd_banner=Welcome to blah FTP service.
          
          96〜98行目
          #chroot_list_enable=YES
          # (default follows)
          #chroot_list_file=/etc/vsftpd.chroot_list
            ホームディレクトリより上層への許可リストの有効化とその許可ユーザーリスト
          chroot_list_enable=YES
          chroot_local_user=YES ← 追加
          # (default follows)
          chroot_list_file=/etc/vsftpd.chroot_list
          local_root=webfiles ← 追加(ユーザーの見えるディレクトリの上限「/home/***/webfiles」)
          
          104行目(上で2行追加しているので実際は+2行)
          #ls_recurse_enable=YES
            ディレクトリの削除を許可
          ls_recurse_enable=YES
          
          107,108行目(上で2行追加しているので実際は+2行)
          userlist_enable=YES
          #enable for standalone mode
            アクセス許可ユーザーリストの有効化とその許可ユーザーリスト
          userlist_enable=YES
          userlist_deny=NO ← 追加
          userlist_file=/etc/vsftpd.user_list ← 追加
          #enable for standalone mode
          
          以下末尾に追加
          use_localtime=YES ← タイムスタンプを日本時間に
          pasv_promiscuous=YES ← PASVモード有効(家からのFTPに必要か疑問はあるが...)
          pasv_min_port=4000 ← PASV開始ポート
          pasv_max_port=4009 ← PASV終了ポート
          

           ホームディレクトリより上層への許可ユーザーリストの作成 -2005年03月22日
          私はホームディレクトリより上層へのアクセスはさせないのでファイルを作るだ
          けです。
          [root@station ~]# touch /etc/vsftpd.chroot_list
          [root@station ~]# chmod 600 /etc/vsftpd.chroot_list
          [root@station ~]#
          
          ユーザー(例:user1)を追加するときは
          
          [root@station ~]# echo user1 >> /etc/vsftpd.chroot_list
          [root@station ~]#
          
          と、するか「vi」などでユーザー名を追加して下さい。
          

           アクセス許可ユーザーリストの編集 -2005年03月22日
          [root@station ~]# vi /etc/vsftpd.user_list
          
          # vsftpd userlist
          # If userlist_deny=NO, only allow users in this file
          # If userlist_deny=YES (default), never allow users in this file, and
          # do not even prompt for a password.
          # Note that the default vsftpd pam config also checks /etc/vsftpd.ftpusers
          # for users that are denied.
          root
          bin
          daemon
          adm
          lp
          sync
          shutdown
          halt
          mail
          news
          uucp
          operator
          games
          nobody
          
           ↓
          
          # vsftpd userlist
          # If userlist_deny=NO, only allow users in this file
          # If userlist_deny=YES (default), never allow users in this file, and
          # do not even prompt for a password.
          # Note that the default vsftpd pam config also checks /etc/vsftpd.ftpusers
          # for users that are denied.
          #root
          #bin
          #daemon
          #adm
          #lp
          #sync
          #shutdown
          #halt
          #mail
          #news
          #uucp
          #operator
          #games
          #nobody
          user1 ← 追加:「user1」にアクセスを許可する時
          

          既に登録済みの各ユーザーのディレクトリにホームページ公開用のディレクトリ
          を作ります。
          質素な作りのスクリプトを用意しました。 使ってやって下さい(涙)
          [root@station ~]# vi sh/webfiles_create.sh
          
          #!/bin/bash
          if [ "$1" = "" ] ; then
          	echo " Usage: webfiles_create.sh username"
          	exit
          fi
          HOME=`grep /etc/passwd -e "^$1"  | cut -d':' -f 6`
          if [ "$HOME" = "" ] ; then
          	echo " user[$1] not found"
          	exit
          fi
          chmod 711 $HOME
          cd $HOME
          mkdir webfiles
          chown $1. webfiles
          chmod 755 webfiles
          mkdir webfiles/public_html
          chown $1. webfiles/public_html
          chmod 755 webfiles/public_html
          mkdir webfiles/cgi-bin
          chown $1. webfiles/cgi-bin
          chmod 755 webfiles/cgi-bin
          
          [root@station ~]# chmod 700 sh/webfiles_create.sh
          [root@station ~]# sh/webfiles_create.sh usre1 ← 「user1」用のディレクトリを作る時
          [root@station ~]#
          

           vsftpdサービスの起動と設定 -2005年03月22日
          [root@station ~]# /etc/init.d/vsftpd start ← vsftpdサービス起動
          vsftpd 用の vsftpd を起動中:                               [  OK  ]
          [root@station ~]# chkconfig vsftpd on ← vsftpdサービス自動起動設定
          [root@station ~]# chkconfig --list vsftpd ← 設定の確認
          vsftpd          0:off   1:off   2:on    3:on    4:on    5:on    6:off ← run level 2〜5の「on」を確認
          [root@station ~]#
          

           「yum」がダウンロードした残骸を消します -2005年03月22日
          「yum」がダウンロードしたファイルがディスクに溜まっているので消します。
          [root@station ~]# yum clean packages
          Cleaning up Packages
          1 packages removed
          [root@station ~]#
          
          すっきり♪