LoginSignup
0
0

More than 3 years have passed since last update.

Debian10 をメインのWSにインストールする

Posted at

注意書き

この記事は、純粋に筆者のメインWSの設定の備忘録として記述していますので、一般的な読者にはほとんど役に立たないと思われます。

設定

NTP

# apt install ntpdate
# ntpdate ntp.nict.jp
# apt install ntp
# vi /etc/ntp.conf

/etc/ntp.conf の設定内容の主要部分は以下の通り。server ディレクティブではなく、pool ディレクティブで指定すると、複数サーバが DNS ラウンドロビンしている場合、適切に複数サーバに展開してくれる。

/etc/ntp.conf
# まず,NICT の NTP サーバを参照する
pool ntp.nict.jp iburst

# 自組織内に NTP サーバが動いているなら,それも参照する
pool ntp.example.net iburst

# ネットワークがダウンしている時のために,サーバ内の CMOS 時計を参照する.信頼度は下げておく.
server 127.127.1.0
fudge 127.127.1.0 stratum 13

OpenLDAP

OpenLDAP サーバと関連ツールをインストール。

# apt install slapd ldap-utils

最近の OpenLDAP は複数ノードのクラスタ化を前提としているので、設定も LDAP 上に格納される。現在の設定内容を調査するには,以下のコマンド。

# slapcat -b cn=config

Samba 用スキーマを導入。samba.ldif は samba パッケージの /usr/share/doc/samba/examples/LDAP/samba.ldif.gz を解凍して使用。

# ldapadd -Y EXTERNAL -H ldapi:/// -f samba.ldif

Dovecot 用スキーマを導入。

# ldapadd -Y EXTERNAL -H ldapi:/// -f mydovecot.ldif

LDAP ツリー全体の suffix および管理者の DN が予定と違っているので修正。

change_rootdn_suffix.ldif
dn: olcDatabase={1}mdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=example,dc=net
-
replace: olcRootDN
olcRootDN: cn=Manager,dc=example,dc=net
# ldapadd -Y EXTERNAL -H ldapi:/// -f change_rootdn_suffix.ldif

uidNumber や sambaSID などの属性のインデックスを作成して、検索の性能を上げておく。および、メール用パスワードなどの ACL を設定する。

config_index_acl.ldif
dn: olcDatabase={1}mdb,cn=config
changetype: modify
replace: olcDbIndex
olcDbIndex: objectClass eq
olcDbIndex: cn eq
olcDbIndex: uid eq,pres,sub
olcDbIndex: uidNumber eq
olcDbIndex: gidNumber eq
olcDbIndex: loginShell eq
olcDbIndex: member eq,pres
olcDbIndex: memberUid eq,pres,sub
olcDbIndex: uniqueMember eq,pres
olcDbIndex: sambaSID eq
olcDbIndex: sambaPrimaryGroupSID eq
olcDbIndex: sambaGroupType eq
olcDbIndex: sambaSIDList eq
olcDbIndex: sambaDomainName eq
olcDbIndex: default sub
-
replace: olcAccess
olcAccess: to attrs=userPassword,shadowLastChange,sambaLMPassword,sambaNTPassword,sambaPasswordHistory
    by dn="cn=Manager,dc=example,dc=net" write
    by self write
    by anonymous auth
    by * none
olcAccess: to attrs=mailPassword
    by dn="cn=Manager,dc=example,dc=net" write
    by dn="cn=dovecot,ou=ACL,dc=example,dc=net" read
    by self write
    by * none
olcAccess: to dn.base=""
    by * read
olcAccess: to *
    by dn="cn=Manager,dc=example,dc=net" write
    by self write
    by * read
# ldapadd -Y EXTERNAL -H ldapi:/// -f config_index_acl.ldif

SSLの設定を行う

ここまでで、一通りの設定が終わっているはずなので、旧サーバの全ユーザエントリを投入する。

# slapadd -l backup.ldif

LDAP に基づいてユーザ認証できるように、必要なパッケージを導入する。

# apt install libnss-ldapd libpam-ldapd
  • nslcd の参照先は、初期値 ldapi:/// のままでよい。
  • libnss-ldapd で管理するデータベースは passwd, group, shadow の3つを指定。なお、正しく設定できているかどうかは、/etc/nsswitch.conf を見ると確認できる。

メールサーバ

IMAPサーバ

# apt install dovecot-imapd dovecot-ldap

新たな dovecont.conf は設定ファイルが細かく分割されているので,見通しが悪い.全体を見るには,以下のコマンドが便利.

# doveconf -n

設定ファイルを編集.

/etc/dovecot/conf.d/10-mail.conf
mail_location = sdbox:~/Mailbox
separator = .
/etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = yes
auth_mechanisms = cram-md5 plain login
!include auth-ldap.conf.ext
/etc/dovecot/conf.d/10-ssl.conf
ssl = yes
ssl_cert = </etc/letsencrypt/live/example.net/fullchain.pem
ssl_key = </etc/letsencrypt/live/example.net/privkey.pem
/etc/dovecot/dovecot-ldap.conf.ext
hosts = example.net
dn = cn=dovecot,ou=ACL,dc=example,dc=net
dnpass = 秘密の文字列
# Use TLS to connect to the LDAP server.
tls = yes
tls_ca_cert_file = /etc/letsencrypt/live/example.net/chain.pem
# 
base = ou=Users,dc=example,dc=net
deref = never
scope = subtree
user_attrs = homeDirectory=home,uidNumber=uid,gidNumber=gid
user_filter = (&(objectClass=posixAccount)(uid=%u))
pass_attrs = uid=user,mailPassword=password
pass_filter = (&(objectClass=posixAccount)(uid=%u))

IMAP over SSL が正常に接続できているかどうかは,以下のコマンドでチェック。

openssl s_client -connect localhost:993 -verify 4

SMTPサーバ

# apt install postfix

基本の「インターネットサイト」を選択した後で、/etc/postfix/main.cf を編集。

/etc/postfix/main.cf
myhostname = example.net
mydestination = example.net, localhost

#mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mynetworks_style = host

mailbox_command = /usr/lib/dovecot/dovecot-lda -f "$SENDER" -a "$RECIPIENT"
mailbox_size_limit = 0
## 50 MB x Base64 (133%) = 66.666 MB
message_size_limit = 67000000

apcupsd

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0