#author("2018-01-12T20:27:57+09:00","hasegawa","hasegawa") #contents *backportsの利用 [#m859f96a] http://backports.debian.org/~ /etc/apt/source.listに deb http://http.debian.net/debian jessie-backports main を追加。 # apt update backportsのpackageをインストールする場合は、 # apt install -t jessie-backports install "package" *追加ソフトのインストール [#d7ca6870] # apt install emacs mew squirrelmail squirrelmail-locales mailman awstats sudo ntp fail2ban *ldapのインポート [#h9125b64] # atp-get install slapd ldap-utils ldap管理者パスワードを適当に設定 # /etc/init.d/slapd stop # dpkg-reconfigure slapd DN名:phys.shinshu-u.ac.jp O名: heplab MDBを選択 slapdをパージした時にデータベースを削除しない 古いldapv2を使わない。 /var/backupに移動する。 現azusa上で、全てのアカウント情報をldif形式のファイルにダンプする。 # /sbin/service slapd stop # /usr/sbin/slapcat -l all.ldif # /sbin/service slapd start ダンプしたファイルを新azusa上にコピーし、不必要な部分(一番上のdn: dc=phys..とdn: cn=admin...のエントリ、この二つは、新azusaにslapdをインストールし、reconfigureしたときに設定しているので、既にエントリに含まれている)を削除する。ou=Groupを追加する。 $ cat >Group.ldif dn: ou=Group,dc=phys,dc=shinshu-u,dc=ac,dc=jp objectClass: organizationalUnit ou: Group ^C $ %%後述するpostfixのメールを受信するために、mailというattributeが必要だが、これはstructural object classのobjectClass: accountではなく、objectClass: inetOrgPersonである。そのため、現azusaからダンプしたそれぞれのエントリに対し、account→inetOrgPersonに置き替え、さらに"sn:"(surnameの意味)と"mail:"のattributeを追加する。%%その後、 # /etc/init.d/slapd stop # /usr/sbin/slapadd -l Group.ldif # /usr/sbin/slapadd -l all.ldif # /etc/init.d/slapd start とすれば良いはず。 *ldapの設定 [#cf2ed74f] **uid>=1000のユーザ(ldapで認証するユーザ)に対して最初にldapで認証する [#z0e5ff91] /etc/pam.d/common-authで、 auth [success=2 default=ignore] pam_unix.so nullok_secure auth [success=1 default=ignore] pam_ldap.so use_first_pass を次のように変更する。 auth [success=1 default=ignore] pam_succeed_if.so uid >= 1000 quiet auth [success=2 default=ignore] pam_unix.so nullok_secure atth [success=1 default=ignore] pam_ldap **passwdでパスワードを変更できるようにする。 [#fce23f66] passwdでパスワードの変更をできるようにするために、/etc/pam.d/common-passwordで password [success=1 user_unknown=ignore default=die] pam_ldap.so use_authtok try_first_pass を password [success=1 user_unknown=ignore default=die] pam_ldap.so try_first_pass に変更する。さらに、簡単なパスワードを禁止する。 # apt-get install libpam-cracklib /etc/pam.d/common-passwordを変更する。 password requisite pam_cracklib.so retry=3 minlen=N dcredit=-n ucredit=-m lcredit=-k ocredit=-l difok=3 などとする。minlen=Nは最低N文字を要求、dcredit=-nは数字がn文字以上含まれる、ucredit=-mは大文字英字がm文字以上含まれる、lcredit=-kは小文字英字がk文字以上含まれる、ocredit=-lは記号がl文字以上含まれることを要求する。 **pam_ldap.secretの設定 [#l80dcb29] passwdで変更できるようにするために、pam_ldap.secretにldap rootのパスワードを書いておく。 # cat (ldap rootのパスワード) > /etc/pam_ldap.secret # chmod 600 /etc/pam_ldap.secret **syslogに"bdb_equality_candidates (uid) not indexed"のようなメッセージが出る場合 [#kb8c095f] ldapmodifyを使う。ただし、cn=admin,cn=configの管理者パスワードolcRootPWが/etc/ldap/slap.d/cn=config/olcDatabase={0}config.ldifに設定されていないので、直接編集して書き込み、設定が終わったらもとに戻す。 $ slappasswd -s password {SSHA}qGQ06BQx2QtRzjQWdTMUph5JJ0hLU/uh これを書き込む $ echo 'olcRootPW: {SSHA}qGQ06BQx2QtRzjQWdTMUph5JJ0hLU/uh' >> /etc/ldap/slap.d/cn\=config/olcDatabase\=\{0\}config.ldif slapdを再起動する。 # /etc/init.d/slapd restart ログにcheck sum errorが出るが、これはファイルを手で編集したため。変更後に編集した部分をもとに戻せばよい。~ 変更する内容を書き込んだファイルを用意する。 $ cat > index.ldif dn: olcDatabase={1}hdb,cn=config changeType: modify add: olcDbIndex olcDbIndex: uid eq ^C 変更する。 # ldapmodify -x -D "cn=admin,cn=config" -W -f index.ldif Enter LDAP Password: password /etc/ldap/slap.d/cn=config/olcDatabase={0}config.ldifをもとに戻して、一応、slapdを再起動。 # /etc/init.d/slapd restart **ldapクライアントの設定 [#o51eacb7] [[計算機関係/Debian(Jessie)をインストール#f2d3ac8a]] *ローカルユーザのインポート [#y3ccc3e8] hepl, tvrec, scecalの/etc/passwd, /etc/shadowをインポートする。 *メールサーバの設定 [#d8cf89e0] **smtpの設定 [#v963072d] このページ - https://wiki.debian.org/Exim - http://flammable.jp/blog/2013/03/debian-squeezesmtp.html - http://www.exim.org/exim-html-current/doc/html/spec_html/ch-encrypted_smtp_connections_using_tlsssl.html を参照。 証明書関係は結局上のURLの通りに設定すればよいのだが、 - http://d.hatena.ne.jp/ozuma/20130510/1368114329 - http://webos-goodies.jp/archives/simple_way_of_creating_ssl_certification.html が参考になる。 **courier-pop, courier-pop-ssl, courier-imap, courier-imap-ssl, courier-ssl, courier-authdaemonのインストール [#u8c2004c] # apt install courier-pop courier-pop-ssl courier-imap courier-imap-ssl courier-ssl courier-authdaemon 自動で証明書が作成されるが、exim4のところで使ったサーバー証明書を流用できる。ただし、dhparams.pemは1024bitでは長さが足りないので、作りなおす。 # openssl dhparam 2048 -out /etc/courier/dhparam.pem # cat /etc/exim4/exim.crt /etc/exim4/exim.key > /etc/courier/imapd.pem # cat /etc/exim4/exim.crt /etc/exim4/exim.key > /etc/courier/pop3d.pem # chmod 644 /etc/courier/*.pem これで、pop3d-ssl, imapd-ssl, smtp-authが使えるはず。 *** FAM/Gaminがうまく動いていない [#i4d4069f] ThunderbirdでIMAPを使っている場合、起動時に次のようなエラーメッセージ Filesystem notification initialization error -- contact your mail administrator (check for configuration errors with the FAM/Gamin library) がでたら、FAMがうまく動いていない模様。代わりにgaminを使う。 # apt install gamin *** ylmf-pcからのEHLOをblockする。 [#kd5d3f33] -exim4の設定でブロックする方法~ /etc/exim4/exim4.conf.templateに acl_smtp_helo = acl_check_helo acl_check_helo: #BEGIN ACL_SMTP_HELO_BLOCK drop condition = ${if eq {$sender_helo_name}{ylmf-pc} {yes}{no}} log_message = HELO/EHLO - ylmf-pc blocked message = I Nailed You at HELO accept #END ACL_SMTP_HELO_BLOCK を追加し、exim4をreload。 - iptablesでブロックする方法 # iptables -A INPUT -p tcp --dport 25 -m string --string 'ylmf-pc' --algo bm -j DROP *spamassassin [#v813bc52] # apt install spamassassin /etc/default/spamassassinで ENABLED=1 とする。 *SquirrelMailの設定 [#xc4927cb] # apt install squirrelmail # ln -s /usr/share/squirrelmail /var/www/html/webmail # /usr/sbin/squirrelmail-configure en_US → ja_JP iso-8859-1 →iso-2022-jp これで日本語にならない場合は、localeにja_JP.EUC-JPがないため。ja_JP.EUC-JPのlocaleを設定するには、 # dpkg-reconfigure -plow locales で、ja_JP.EUC-JPを選択する。 # ln -s /etc/squirrelmail/apache.conf /etc/apache2/site-available # a2ensite apache.conf # /etc/init.d/apache2 reload で、http://hepl.shinshu-u.ac.jp/squirrelmailでアクセスできるはず。 **ユーザ設定・アドレス帳のインポート [#gbff44d2] (ユーザ名).pref, (ユーザ名).abook, (ユーザ名).sigと言うファイルが /var/lib/squirrelmail/data (debian) (squirrelmailのソースファイルへのパス)/squirrelmail/data (vine) 以下にあるので、それをコピーする。 # rsync -e ssh -rlopgt /var/lib/squirrelmail/data (新azusa):/var/lib/squirrelmail **sslを使ったアクセスに限定する。 [#u6977312] /etc/squirrelmail/apache.confの最後にhttpをhttpsに強制的に書き換える方法がある。ここを有効にする。<Location /squirrelmail>を適当に変更する。このサイトでsslを有効にしなければならないので、/etc/apache2/sites-available/default-sslのDocumentRootを適当に変更する。 # a2ensite default-ssl # a2enmod ssl # a2enmod rewrite を行う。 *mewの設定 [#u2204d2c] ローカルユーザもpop,imap,smtpを利用する際に認証が必要となる。特に、smtpでメールを送る際に.mew.elでmew-smtp-userの設定が必要になる。 (setq mew-smtp-user "ユーザID") pop3,imapはmew-pop-user, mew-imap-userにログイン名(ユーザID)がデフォルト値になっているので設定する必要がないが、mew-smtp-userのデフォルト値は"ユーザID@azusa.shinshu-u.ac.jp"になっているので、この値を設定しないと、認証できなくなる。 *apache2の設定 [#xca16e85] -default設定をカスタマイズ~ 現行azusaから、/etc/apache2/site-available/default.hepl.confとdefault-ssl.hepl.confをコピーする(a2enmodは拡張子に.confがないとERROR: Site XXX does not exist!とエラーとなる)。 -ユーザのpublic_htmlをみられるようにする。/etc/apache2/mod-availableに利用可能なモジュールがあるので、この中の、userdirがそのモジュール。有効にするには、 # a2enmod userdir *mailman [#d3379e25] mailmanをインストール # apt-get install mailman サイトリストがない、と言ってくるが、設定ファイルやアーカイブをまるごとコピーすればよいはず。/var/lib/mailman/以下をコピーすればよいはず。 # rsync -e ssh -rlopgt /var/lib/mailman newdomain.shinshu-u.ac.jp:/var/lib # rsync -e ssh -rlopgt /etc/mailman newdomain.shinshu-u.ac.jp:/etc %%インストール終了後作成する。%% # newlist mailman ←不要 %%mailman で予め listname でメーリングリストを作成し、必要な設定をしておく。%% /etc/mailman/mm_cfg.pyを適当に編集。ドメイン名(azusa.shinshu-u.ac.jp)を変更しなければ、編集不要。変更する場合は、 DEFAULT_URL_HOST = 'newdomain.shinshu-u.ac.jp' などとする。インポートしたメーリングリストのurlの変更と、アーカイブのurlも変更する。 # cd /var/lib/mailman/bin # ./mainmanctl stop # ./withlist -l -r fix_url he -u newdomain.shinshu-u.ac.jp # ./arch --wipe he # ./mainmanctl start mailmanの設定例~ http://fedorasrv.com/postfix-mailman.shtml~ http://www.exim.org/howto/mailman21.html~ mailman main, mailman router, mailman transportの設定が必要。~ 特に、 OWNERS_CAN_DELETE_THEIR_OWN_LISTS = Yes ← メーリングリストをWeb上から削除可能にする を設定すると便利。 -exim4を設定する。[[このページ>http://www.debian-administration.org/article/Mailman_and_Exim4]]を参考。 **mailmanでillegal multibyteエラーが出て、digestが送れない。 [#a2978b27] [[このページ>http://www.yosakoi-dance.net/blog/?p=8042]]を参照。 *awstats [#w26dcdd3] /etc/awstats/awstats.conf, awstats.conf.localを引き継ぐ。/etc/apache2/sites-available/default.heplをファイルを引き継ぎ、 # a2ensite default.hepl # /etc/init.d/apache2 reload する。cronの設定を変更する。/etc/cron.d/awstatsで、実行ユーザをrootに変更。/etc/cron.daily/awstatsを引き継ぐ。 *pukiwikiの変更 [#l7e3ec43] pukiwiki-1.4.7_notb.tar.gzがphp5.4に対応していないので、ソースを変更する。 -http://www.seichan.org/blog/2013/12/post-193.html -http://www.seichan.org/blog/2013/12/post-208.html -ereg->preg_match -split->preg_split -日本語エンコーディング~ http://www.kankaz.net/blog/?p=17 **euc-jpからutf-8へ変更 [#b4e2657d] このページ~ http://nemusg.com/archives/pukiwiki-utf8.html~ を参照。wiki, attachなどのページが変換できれば、phpのバージョンに対応させるより、1.5.1-utf8をスクラッチからインストールして、ファイルをコピーしたほうが早い。変換のコツは日本語名の添付ファイルを日本語を使わない名前に変更しておくこと。EUC-JPと比べてUTF-8はwiki名が1.5倍の長さになるので、linuxのファイル名の長さの制限(<2000)に引っかかるため。 *wordpress [#g31bc390] debain jessie https://wiki.debian.org/WordPress~ 日本語リソースの追加 https://ja.wordpress.org/install-ja/~ *dns [#m276b13a] # apt install bind9 現azusaから/etc/bind以下をコピー。 **エラー named error (insecurity proof failed) resolvingが出た場合 [#z4a59995] /etc/bind/named.conf.optionsで、 dnssec-validation no; <-autoから とする。http://blog.livedoor.jp/haruchaco/archives/1610376.html参照。 *iptables [#y121a5ce] ルータを導入したので、ルータで設定する。 # apt-get install iptables-persistent 現azusaからazusa-iptables.060914をコピー。 *ビデオサーバー [#kba693c2] /etc/apt/source.listに deb http://deb-multimedia.org jessie main を追加。 # apt install ffmpeg 現azusaから/var/www/.ssh以下をコピー。www-dataにowner,groupを変更。 *fail2ban [#y1d8b319] denyhostsがjessieから削除されたので、代替のfail2banを使う。 # apt install fail2ban iptablesにルールを設定する模様。設定例https://www.chrissearle.org/2015/06/16/replacing-denyhosts-with-fail2ban-for-debian/ *phpMyAdmin [#s0a3c2ec] # a2enconf phpmyadmin # service apache2 reload で,http://azusa.shinshu-u.ac.jp/phpmyadminでアクセスする。wordpressのデータベースを移行すればよいはず。 [[研究室関係]]