Debian

彩色終端的配置

debian:~# cat .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.

export PS1='\h:\w\$ '
umask 022

# You may uncomment the following lines if you want `ls' to be colorized:
# export LS_OPTIONS='--color=auto'
# eval `dircolors`
# alias ls='ls $LS_OPTIONS'
# alias ll='ls $LS_OPTIONS -l'
# alias l='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'
debian:~#
		

去掉註釋

debian:~# vi .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.

export PS1='\h:\w\$ '
umask 022

# You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
eval `dircolors`
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
		
debian:~# logout
		

Debian 預設[HOME][END]鍵沒有開放,習慣了Redhat人用着可不爽,開啟它。

debian:~# vi /etc/inputrc
# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line
		

logout註銷後再登錄即可.

安裝配置OpenLDAP

  1. 通過apt-get安裝OpenLDAP

    debian:~# apt-get install slapd
    			
    
Do you want to continue? [Y/n]
    
    Debian Configuration
    
        ┌────────────┤ Configuring slapd ├─────────────┐
        │ The DNS domain name is used to construct the base DN of your LDAP   │
        │ directory. Entering foo.bar.org will give you the base DN dc=foo,   │
        │ dc=bar, dc=org.                                                     │
        │                                                                     │
        │ Enter your DNS domain name                                          │
        │                                                                     │
        │ example.net________________________________________________________ │
        │                                                                     │
        │                               <Ok>                                  │
        │                                                                     │
        └─────────────────────────────────────┘
    裡是請輸入你的域名例如:example.net = dc=example,dc=net
    
    Debian Configuration
    
     ┌────────────┤ Configuring slapd ├────────────────┐
     │ Whatever you enter here will be stored as the name of your organization   │
     │ in the base DN of your LDAP directory.                                    │
     │                                                                           │
     │ Enter the name of your organization                                       │
     │                                                                           │
     │ netkiller ______________________________________________________________ │
     │                                                                           │
     │                                  <Ok>                                     │
     │                                                                           │
     └────────────────────────────────────────┘
    這裡輸入組織名即ou=postfix
    
    Debian Configuration
    
      ┌────────────┤ Configuring slapd ├───────────────┐
      │  Please enter the password for the admin entry in your LDAP directory.  │
      │                                                                         │
      │ Admin password                                                          │
      │                                                                         │
      │ _______________________________________________________________________ │
      │                                                                         │
      │                                 <Ok>                                    │
      │                                                                         │
      └───────────────────────────────────────┘
    輸入密碼
    
    Debian Configuration
    
      ┌──────────────┤ Configuring slapd ├──────────────┐
      │                                                                          │
      │ slapd now defaults to having the old LDAPv2 protocol not allowed.        │
      │ Programs and users are generally expected to be upgraded to LDAPv3. If   │
      │ you have old programs which have not been moved to use LDAPv3 and you    │
      │ still need LDAPv2 support then select this option and 'allow bind_v2'    │
      │ will be added to your slapd.conf to tell slapd to accept LDAPv2          │
      │ connections.                                                             │
      │                                                                          │
      │ Allow LDAPv2 protocol                                                    │
      │                                                                          │
      │                    <Yes>                       <No>                      │
      │                                                                          │
      └────────────────────────────────────────┘
    再輸入一次
    
    Starting OpenLDAP: slapd.
    			
  2. 安裝輔助工具

    debian:~# apt-get install ldap-utils migrationtools
    			
  3. Debian OpenLDAP 與Redhat OpenLDAP配置很不同,要註冊一點,redhat是配置檔案中指定ldap管理員 'cn=manager,dc=example,dc=net'注意"cn=manager,dc=example,dc=net"並不存在於LDAP資料庫中ldapsearch 也看不到有此項條目,而Debian是管理員是通過ldapadd加入的"cn=admin,dc=example,dc=net",它是存在於LDAP 資料庫中的,並用 ldapsearch -x -D 'cn=admin,dc=example,dc=net' -b 'dc=example,dc=net' 'objectclass=*' namingContexts -w chen 可以列出該條目

    debian:~# ldapsearch -x -D 'cn=admin,dc=example,dc=net' -b 'dc=example,dc=net' 'objectclass=*' namingContexts -w chen
    # extended LDIF
    #
    # LDAPv3
    # base <dc=example,dc=net> with scope sub
    # filter: objectclass=*
    # requesting: namingContexts
    #
    
    # example.net
    dn: dc=example,dc=net
    
    # admin, example.net
    dn: cn=admin,dc=example,dc=net
    
    # people, example.net
    dn: ou=people,dc=example,dc=net
    
    # postfix, example.net
    dn: ou=postfix,dc=example,dc=net
    
    # courier, postfix, example.net
    dn: cn=courier,ou=postfix,dc=example,dc=net
    
    # chen, postfix, example.net
    dn: uid=chen,ou=postfix,dc=example,dc=net
    
    # search result
    search: 2
    result: 0 Success
    
    # numResponses: 7
    # numEntries: 6
    debian:~#
    		
  4. postfix.schema

    創建Schema檔案,在/etc/ldap/schema/目錄下創建名為postfix.schema的檔案

    debian:~# cd /etc/ldap/schema/
    debian:/etc/ldap/schema# cat postfix.schema
    #
    # postfix-ldap directory schema v0.1
    #
    # Created by: netkiller <openunix@163.com>
    # Created: 2004-4-12
    #
    # Note: The attribute and objectclass OIDs are valid
    #
    
    # Attribute Type Definitions
    
    
    # Postfix Style
    
    #attributetype ( 1.3.6.1.4.1.7006.1.2.1.1 NAME 'uidnumber'
            DESC 'UID of the user on the mailsystem'
            EQUALITY integerMatch
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
    
    #attributetype ( 1.3.6.1.4.1.7006.1.2.1.2 NAME 'gidnumber'
            DESC 'GID of the user on the mailsystem'
            EQUALITY integerMatch
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
    
    attributetype ( 1.3.6.1.4.1.12461.1.1.5 NAME 'mailbox'
            DESC 'The absolute path to the mailbox for a mail account in a non-default location'
            EQUALITY caseExactIA5Match
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
    
    attributetype ( 1.3.6.1.4.1.12461.1.1.6 NAME 'quota'
            DESC 'A string that represents the quota on a mailbox'
            EQUALITY caseExactIA5Match
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
    
    attributetype ( 1.3.6.1.4.1.12461.1.1.8 NAME 'maildrop'
            DESC 'RFC822 Mailbox - mail alias'
            EQUALITY caseIgnoreIA5Match
            SUBSTR caseIgnoreIA5SubstringsMatch
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
    
    attributetype ( 1.3.6.1.4.1.12461.1.1.7 NAME 'clearPassword'
            DESC 'A separate text that stores the mail account password in clear text'
            EQUALITY octetStringMatch
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128})
    
    
    attributetype ( 1.3.6.1.4.1.12461.1.1.9 NAME 'mailsource'
            DESC 'Message source'
            EQUALITY caseIgnoreIA5Match
            SUBSTR caseIgnoreIA5SubstringsMatch
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
    
    # Qmail Style
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.1 NAME 'qmailUID'
            DESC 'UID of the user on the mailsystem'
            EQUALITY integerMatch
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.2 NAME 'qmailGID'
            DESC 'GID of the user on the mailsystem'
            EQUALITY integerMatch
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.3 NAME 'mailMessageStore'
            DESC 'Path to the maildir/mbox on the mail system'
            EQUALITY caseExactIA5Match
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.4 NAME 'mailAlternateAddress'
            DESC 'Secondary (alias) mailaddresses for the same user'
            EQUALITY caseIgnoreIA5Match
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.5 NAME 'mailQuota'
            DESC 'The amount of space the user can use until all further messages get bounced.'
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.6 NAME 'mailHost'
            DESC 'On which qmail server the messagestore of this user is located.'
            EQUALITY caseIgnoreIA5Match
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.7 NAME 'mailForwardingAddress'
            DESC 'Address(es) to forward all incoming messages to.'
            EQUALITY caseIgnoreIA5Match
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.8 NAME 'deliveryProgramPath'
            DESC 'Program to execute for all incoming mails.'
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.9 NAME 'qmailDotMode'
            DESC 'Interpretation of .qmail files: both, dotonly, ldaponly, ldapwithprog, none'
            EQUALITY caseIgnoreIA5Match
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.10 NAME 'deliveryMode'
            DESC 'multi field entries of: normal, forwardonly, nombox, localdelivery, reply, echo'
            EQUALITY caseIgnoreIA5Match
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.11 NAME 'mailReplyText'
            DESC 'A reply text for every incoming message'
            SUBSTR caseIgnoreSubstringsMatch
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} SINGLE-VALUE )
    
    attributetype ( 1.3.6.1.4.1.7006.1.2.1.12 NAME 'accountStatus'
            DESC 'The status of a user account: active, nopop, disabled'
            EQUALITY caseIgnoreIA5Match
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
    
    # Postfix Virtual Domain
    
    attributetype ( 1.3.6.1.4.1.12461.1.1.4 NAME 'vd'
            DESC 'A virtual domain managed by Jamm'
            EQUALITY caseIgnoreIA5Match
            SUBSTR caseIgnoreIA5SubstringsMatch
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
    
    attributetype ( 1.3.6.1.4.1.12461.1.1.1 NAME 'transport'
            DESC 'A string directing postfix which transport to use'
            EQUALITY caseExactIA5Match
            SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{20} SINGLE-VALUE )
    
    # Object Class Definitions
    
    objectclass ( 1.3.6.1.4.1.12461.1.2.1 NAME 'postfixAccount'
            DESC 'Postfix-LDAP User' SUP top AUXILIARY
            MUST ( mail $ uid )
            MAY ( mailbox $ quota $ maildrop $ clearPassword $
                  mailMessageStore $ homeDirectory $ userPassword $
                  mailAlternateAddress $ uidnumber $ gidnumber $ mailQuota $
                  mailHost $ mailForwardingAddress $ mailReplyText $
                  accountStatus ) )
    
    objectclass ( 1.3.6.1.4.1.12461.1.2.2 NAME 'postfixAliases'
            SUP top STRUCTURAL
            DESC 'Mail aliasing/forwarding entry'
            MUST ( mail $ uid )
            MAY ( maildrop $ description $ mailForwardingAddress $ accountStatus ) )
    
    objectclass ( 1.3.6.1.4.1.12461.1.2.3 NAME 'postfixVirtualDomain'
            SUP top STRUCTURAL
            DESC 'Virtual Domain entry to be used with postfix transport maps'
            MUST ( vd $ transport )
            MAY ( o $ description $ accountStatus ) )
    
    # Qmail Object Class Definitions
    objectclass ( 1.3.6.1.4.1.7006.1.2.2.1 NAME 'qmailUser'
            DESC 'QMail-LDAP User' SUP top AUXILIARY
            MUST ( mail $ uid )
            MAY ( mailMessageStore $ homeDirectory $ userPassword $
                  mailAlternateAddress $ qmailUID $ qmailGID $ mailQuota $
                  mailHost $ mailForwardingAddress $ deliveryProgramPath $
                  qmailDotMode $ deliveryMode $ mailReplyText $
                  accountStatus ) )
    debian:/etc/ldap/schema#
    			
  5. slapd.conf

    配置slapd.conf檔案,在include位置加入:

    debian:/etc/ldap# vi slapd.conf
    include         /etc/ldap/schema/postfix.schema
    			
  6. reload slapd

    debian:/etc/ldap# /etc/init.d/slapd force-reload