2015年1月15日木曜日

ファイルサーバの構築実験

実験の目的

  • Linuxをファイルサーバとして利用できるようにする

方法

  1. LinuxにSambaをインストールして共有フォルダを作成する
  2. 作成した共有フォルダを同一LAN内に設置したWindowsパソコンからアクセスできるようにする

VPNの構築実験

実験の目的

  • リモートアクセスVPNを構築して,インターネット経由で遠隔地にあるパソコンやスマートフォンから内部ネットワークに安全にアクセスできる通信路を構築する

使用するVPNソフトウェア

  • SoftEther VPN server

方法

  1. Linuxサーバ(CentOS 5.1)にSoftEther VPN server をインストールする
  2. WindowsパソコンにVPN server 管理マネジャをインストールする
  3. VPNサーバマネージャを使ってVPN serverの設定を行(L2TP/IPsec, 仮想NAT, ダイナミックDNS, Azure VPN Cloud)
  4. スマートフォンからL2TP/IPsecでVPNサーバに接続する
  5. 遠隔地にあるWindowsからSSTPでVPNサーバに接続する
  6. 内部ネットワークにWindowsパソコンを設置し,遠隔地にあるWindowsからリモートデスクトップでWindowsパソコンに接続する
  7. 内部ネットワークに設置したWindowsパソコンに共有フォルダを作成する
  8. スマートフォンにファイラー(例えばFileBrowserLite)をインストールして,VPN接続したスマートフォンから内部ネットワークに接続したWindowsパソコンの共有フォルダにアクセスする






2015年1月14日水曜日

SSLの構築実験

    実験の目的

    • Webサーバ(apache)でSSLが使えるように設定して,安全な通信路を確保する

    方法

    1. 認証局(自己認証局)を構築する
    2. サーバ証明書を生成する
    3. apacheにSSLを設定する
    4. SquirrelMail, Wordpress, phpMyAdminはSSLでなければ接続できないようにする(SSL必須の設定)


    2014年11月22日土曜日

    OP25BとSubmission587

    OP25B対策には以下の2種類がある

    (1)実験サーバSMTPサーバ(SMTP構内)から外部へ送信する場合
    (2)外部(たとえばPlala構内)から実験サーバSMTPサーバ(SMTP構内)に接続(メールを受けとるという意味では受信)する場合

    (1)に対する対策

    /etc/postfix/main.cfに書きを追加

    relayhost = [smtp.poem.ocn.ne.jp]

    これは,外部へ送信する場合,OCNのメールサーバを中継する設定である。

    (2)に対する対策

    ①cyrus-saslのインストール

    # /usr/sbin/postconf -a
    cyrus
    dovecot

    # sudo rpm -qa | grep cyrus-sasl
    cyrus-sasl-2.1.22-7.el5_8.1
    cyrus-sasl-lib-2.1.22-7.el5_8.1
    cyrus-sasl-plain-2.1.22-7.el5_8.1

    # sudo yum -y install cyrus-sasl-md5
    # sudo yum -y install cyrus-sasl-plain

    # sudo rpm -qa | grep cyrus-sasl
    cyrus-sasl-2.1.22-7.el5_8.1
    cyrus-sasl-lib-2.1.22-7.el5_8.1
    cyrus-sasl-plain-2.1.22-7.el5_8.1
    cyrus-sasl-md5-2.1.22-7.el5_8.1

    ②パスワードの設定

    # sudo /usr/sbin/saslpasswd2 -c -u some.domain.jp userAccount

    # /usr/sbin/sasldblistusers2
    userAccount@some.domain.jp: userPassword

    ※削除する場合
    # sudo /usr/sbin/saslpasswd2 -d -u some.domai.jp userAccount

    ③データベースのオーナーをpostfixに変更

    # sudo chown postfix /etc/sasldb2

    ④Postfixの設定(SMTP AUTHの設定)

    $ sudo vim /etc/postfix/main.cf
    # SMTP AUTH
    smtpd_sasl_auth_enable=yes
    smtpd_sasl_local_domain=$mydomain
    smtpd_recipient_restrictions=
      permit_mynetworks,
      permit_sasl_authenticated,
      reject_unauth_destination
    smtpd_sasl_security_options=noanonymous,noplaintext

    ⑤確認テスト

    # telnet localhost 25
    Trying 127.0.0.1...
    Connected to localhost.localdomain (127.0.0.1).
    Escape character is '^]'.
    220 kumw-hinfo.ddo.jp ESMTP Postfix
    EHLO localhost
    250-kumw-hinfo.ddo.jp
    250-PIPELINING
    250-SIZE 10240000
    250-VRFY
    250-ETRN
    250-AUTH DIGEST-MD5 CRAM-MD5
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250 DSN

    【参考】

    OP25B対策(Outbound Port 25 Blocking対策)
    http://www.aconus.com/~oyaji/mail2/op25b.htm

    ⑥Submission587の設定

    /etc/postfix/master.cf

    # ==========================================================================
    # service type  private unpriv  chroot  wakeup  maxproc command + args
    #               (yes)   (yes)   (yes)   (never) (100)
    # ==========================================================================
    smtp      inet  n       -       n       -       -       smtpd
    #submission inet n       -       n       -       -       smtpd
    #  -o smtpd_enforce_tls=yes
    #  -o smtpd_sasl_auth_enable=yes
    #  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

      ↓

    submission inet n      -       n       -       -       smtpd
      -o smtpd_etrn_restrictions=reject
      -o smtpd_client_restrictions=permit_sasl_authenticated,reject

    ⑦ファイアウォールの設定(port587に穴を開ける)

    /etc/sysconfig/iptables
    -A RH-Firewall-1-INPUT -p tcp -m tcp --dport 587 -j ACCEPT

    /etc/postfix/main.cf
    mynetworks = xxx.xxx.xxx.xxx/32, 127.0.0.0/8, xxx.xxx.xxx.xxx/32

    【参考】
    Postfix + Cyrus SASL で SMTP AUTH を設定した
    http://www.1x1.jp/blog/2012/10/postfix_and_cyrus_sasl2_stmp_auth.html

    2014年11月20日木曜日

    OP25B

    プロバイダが行っているスパム対策:OP25Bのために,smtpサーバがメールを送信できないという問題がある。その対策として,postfixの設定で,relayhostにプロバイダのメールサーバを設定するという方法がある。詳細は「餅ちゃんの備忘録」を参照。
    具体的には,/etc/postfix/main.cfに以下の一文を設定するだけ。

    relayhost = [smtp.poem.ocn.ne.jp]



    2014年11月19日水曜日

    Webサーバ構築

    Apache+PHPをインストールする

    #yum install httpd php

    Webコンテンツを修正できるグループを作成してメンバを登録する

    # groupadd www
    # usermod -G www user
    # chown -R root:www /var/www
    # chmod -R g+w /var/www

    公開鍵認証

    http://www.websec-room.com/2014/01/18/1647
    chmod 700 ~/.sshを忘れないこと!
    /etc/ssh/sshd_confでPubkeyAuthentication yesのコメントを外すことを忘れないこと

    WinSCPのためのPuTTY用の秘密鍵の作成

    http://www.websec-room.com/2014/01/18/1647
    WinSCPを使って、imagesフォルダとstyle.cssをアップロード

    2014年10月24日金曜日

    ユーザとグループの概念

    • ユーザ
      • システム上に登録されたアカウントを持つメンバ
      • ユーザは/etc/passwdに登録される
      • パスワードは/etc/shadowに登録される
    • グループ
      • 単独もしくは複数のユーザから構成され、システムに対する権限を与えたり限定したりするために使用される
      • グループは/etc/groupへ登録される

    コマンド
    • ユーザ登録(useradd)
    • パスワード設定(passwd)
    • グループ登録(groupadd)
    • ユーザの属するメイングループの変更(usermod -g)
      • usermod -g グループ名 ユーザ名
    • ユーザの補助グループを登録する(usermod -G)
      • usermod -G グループ名 ユーザ名
    • ユーザから所属する補助グループを削除(gpasswd)
      • gpasswd -d ユーザ名 グループ名