顯示具有 Server::LDAP Server 標籤的文章。 顯示所有文章
顯示具有 Server::LDAP Server 標籤的文章。 顯示所有文章

2022年12月4日 星期日

在 CentOS / RHEL 8上安裝 389 Directory Server

學習目標:
  • 安裝企業級 LDAP 服務:389 Directory Server (389 DS)
安裝設定流程:
  1. 安裝 389 DS 基礎套件:
    # yum upgrade
    # dnf copr enable @389ds/389-directory-server
    # dnf install 389-ds-base cockpit-389-ds
    # yum install cockpit*
    
  2. 開啟瀏覽器,登入 https://localhost:9090 網址,選擇 389 Directory Server,按下 Create New Instance 按鍵:

  3. 輸入相關欄位資料,用來建立新的實例:

  4. 更改主機名稱設定:

  5. 在按下 Save Setting 之後,記得按 Action 進行重新啟動~~
  6. 切換至 Database 標籤,按下 Create Suffix :

  7. 輸入資料之後,按下 Create Suffix:

  8. 確定 Suffix 是否被建立:

  9. PS: 若不想使用 Cockpit 企面,可在啟動 389 DS 之前,利用編寫基本設定檔,導入系統中:
    # vim /root/instance.inf
    [general]
    config_version = 2
    
    [slapd]
    root_password = 這裡放管理者密碼
    
    [backend-userroot]
    sample_entries = yes
    suffix = dc=example,dc=com
    
    # dscreate from-file /root/instance.inf
    
  10. 開啟防火牆設定:
    # firewall-cmd --add-port={389/tcp,636/tcp}
    # firewall-cmd --add-port={389/tcp,636/tcp} --permanent
      
  11. 查詢運作中的 389 DS Server
    # dsctl ds1 status
    Instance "ds1" is running
    

使用方式:
  1. 在本機上設定管理 389 DS Server:
    # vim ~/.dsrc
    [ds1]
    # Note that '/' is replaced to '%%2f'.
    uri = ldapi://%%2fvar%%2frun%%2fslapd-ds1.socket
    basedn = dc=example,dc=com
    binddn = cn=Directory Manager
    
  2. 新增使用者: (系統上並不需要建立該使用者帳號)
    # dsidm ds1 user create
    Enter password for cn=Directory Manager on ldaps://ds1.example.com:
    Enter value for uid : alice
    Enter value for cn : Alice
    Enter value for displayName : Alice User
    Enter value for uidNumber : 1000
    Enter value for gidNumber : 1000
    Enter value for homeDirectory : /home/alice
    Sucessfully created alice
    
    # dsidm ds1 user get alice
    
參考文獻:
  • https://directory.fedoraproject.org/docs/389ds/howto/quickstart.html
  • https://directory.fedoraproject.org/docs/389ds/download.html
  • https://www.techsupportpk.com/2020/04/how-to-set-up-389-directory-server-centos-rhel-8.html
  • https://access.redhat.com/documentation/en-us/red_hat_directory_server/12
  • 2018年10月29日 星期一

    在 CentOS / RHEL 7 上,安裝 FreedIPA 服務

    學習目標:
    • 在 CentOS / RHEL 7 Linux 作業系統上,安裝 FreeIPA 服務!
    • 需要先架設好自有 DNS Server !
    安裝設定流程:
    1. 安裝相關必要軟體安裝工作!
      # yum -y upgrade
      # reboot
      
    2. 設定主機名稱:
      # hostnamectl set-hostname dns.example.com
      # echo "192.168.100.120 dns.example.com dns" >> /etc/hosts
      # echo "nameserver 127.0.0.1" > /etc/resolv.conf
      
    3. 安裝 IPA Server 套件軟體!
      # yum install -y ipa-server ipa-server-dns
      
    4. 進行設定 IPA Server 工作!
      # ipa-server-install --setup-dns
      (以下就依實際需要修改!)
      Server host name [dns.example.com]:
      Please confirm the domain name [example.com]:
      Please provide a realm name [EXAMPLE.COM]:
      Directory Manager password:
      Password (confirm):
      IPA admin password: 
      Password (confirm):
      Do you want to configure DNS forwarders? [yes]:
      Do you want to configure these servers as DNS forwarders? [yes]: no
      Enter an IP address for a DNS forwarder, or press Enter to skip:
      Do you want to search for missing reverse zones? [yes]:
      Continue to configure the system with these values? [no]: yes
      ...略...
      (看到以下項目,表示安裝成功!)
      ==============================================================================
      Setup complete
      
      Next steps:
       1. You must make sure these network ports are open:
        TCP Ports:
          * 80, 443: HTTP/HTTPS
          * 389, 636: LDAP/LDAPS
          * 88, 464: kerberos
          * 53: bind
        UDP Ports:
          * 88, 464: kerberos
          * 53: bind
          * 123: ntp
      
       2. You can now obtain a kerberos ticket using the command: 'kinit admin'
          This ticket will allow you to use the IPA tools (e.g., ipa user-add)
          and the web user interface.
      
      Be sure to back up the CA certificates stored in /root/cacert.p12
      These files are required to create replicas. The password for these
      files is the Directory Manager password
      
    5. 進行初始化設定:
      # kinit admin
      Password for admin@EXAMPLE.COM:
      
    6. 進行檢查列表:
      # klist
      Ticket cache: KEYRING:persistent:0:0
      Default principal: admin@EXAMPLE.COM
      
      Valid starting       Expires              Service principal
      2018-10-29T12:25:08  2018-10-30T12:24:57  krbtgt/EXAMPLE.COM@EXAMPLE.COM
      
    7. 更改常用的 shell :
      # ipa config-mod --defaultshell=/bin/bash 
      
    8. 設定防火牆!
      # firewall-cmd --add-service={http,https,freeipa-ldap,freeipa-ldaps,dns,ntp,kerberos} --permanent
      # firewall-cmd --reload
      

    參考文獻:
    • https://www.server-world.info/en/note?os=CentOS_7&p=ipa&f=1
    • https://www.howtoing.com/how-to-set-up-centralized-linux-authentication-with-freeipa-on-centos-7

    2016年5月17日 星期二

    在 CentOS7/RHEL7 上安裝設定 LDAP Server(二)

    進階設定目標:
    • 將公鑰遞給客戶端,用以建立 TLS 連線方式,使用 LDAP Server!
    進階設定流程:
    1. 切換目錄至 /etc/openldap/certs/:
      #cd /etc/openldap/certs/
      
    2. 複製公鑰至公開目錄,方便客戶端取得:
      #cp cert.pem /var/www/html/example-ca.crt
      
    3. 小心 SELinux 問題:
      #restorecon -R /var/www/html
      
    4. 重新啟動 Apache 服務:
      #systemctl restart httpd
      

    客戶端設定:
        圖形介面安裝設定:
    1. 首先安裝認證設定圖形介面套件:
      #yum -y install authconfig-gtk
      
    2. 在 Gnome 圖形介面下,打開認證設定軟體:
      #authconfig-gtk &
      

    2016年5月8日 星期日

    在 CentOS7/RHEL7 上安裝設定 LDAP Server(一)

    快速設定流程:
    1. 安裝 LDAP Server 套件:
      #yum install -y openldap openldap-clients openldap-servers migrationtools
      
    2. 先取得加密後的密碼:
      #slappasswd -s redhat -n > /etc/openldap/passwd
      
    3. 製作加密通訊用的金鑰組:
      #openssl req -new -x509 -nodes -out /etc/openldap/certs/cert.pem -keyout /etc/openldap/certs/priv.pem -days 3650
      Generating a 2048 bit RSA private key
      .....+++
      ..............+++
      writing new private key to '/etc/openldap/certs/priv.pem'
      -----
      You are about to be asked to enter information that will be incorporated
      into your certificate request.
      What you are about to enter is what is called a Distinguished Name or a DN.
      There are quite a few fields but you can leave some blank
      For some fields there will be a default value,
      If you enter '.', the field will be left blank.
      -----
      Country Name (2 letter code) [XX]:  ##輸入國別
      State or Province Name (full name) []: ##輸入省名
      Locality Name (eg, city) [Default City]: ##輸入城市名
      Organization Name (eg, company) [Default Company Ltd]: ##輸入組織名
      Organizational Unit Name (eg, section) []: ##輸入組織名
      Common Name (eg, your name or your server's hostname) []:instructor.example.com
      Email Address []: ##輸入 email 帳號
      
    4. 修改 /etc/openldap/certs 權限:
      # cd /etc/openldap/certs
      # chown ldap:ldap *
      # chmod 600 priv.pem
      
    5. 將 LDAP 資料庫範例檔,直接複製過來,方便架設與安裝:
      #cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
      #chown ldap /var/lib/ldap/DB_CONFIG
      
    6. 產生資料庫檔(不用管出現的錯誤):
      #slaptest
      
    7. 設定 /var/lib/ldap/ 目錄內,相關檔案權限:
      ## chown ldap:ldap /var/lib/ldap/*
      
    8. 防火牆設定(389/686 port):
      #firewall-cmd --permanent --add-service=ldap
      #firewall-cmd --permanent --add-service=ldaps
      #firewall-cmd --reload
      
    9. 啟動 slapd 服務:
      #systemctl enable slapd.service
      #systemctl start slapd.service
      
    10. 檢查啟動狀況:
      #ss -nlp | grep slapd
      
    11. 將 ldif 檔案導入系統中,例如: cosine 以及 nis 兩個 schemas:
      #cd /etc/openldap/schema
      #ldapadd -Y EXTERNAL -H ldapi:/// -D "cn=config" -f cosine.ldif
      #ldapadd -Y EXTERNAL -H ldapi:/// -D "cn=config" -f nis.ldif
      
    12. 編寫 changes.ldif 檔案:
      #vim /etc/openldap/changes.ldif
      dn: olcDatabase={2}hdb,cn=config
      changetype: modify
      replace: olcSuffix
      olcSuffix: dc=example,dc=com
      
      dn: olcDatabase={2}hdb,cn=config
      changetype: modify
      replace: olcRootDN
      olcRootDN: cn=Manager,dc=example,dc=com
      
      dn: olcDatabase={2}hdb,cn=config
      changetype: modify
      replace: olcRootPW
      olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx
      
      dn: cn=config
      changetype: modify
      replace: olcTLSCertificateFile
      olcTLSCertificateFile: /etc/openldap/certs/cert.pem
      
      dn: cn=config
      changetype: modify
      replace: olcTLSCertificateKeyFile
      olcTLSCertificateKeyFile: /etc/openldap/certs/priv.pem
      
      dn: cn=config
      changetype: modify
      replace: olcLogLevel
      olcLogLevel: -1
      
      dn: olcDatabase={1}monitor,cn=config
      changetype: modify
      replace: olcAccess
      olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read by dn.base="cn=Manager,dc=example,dc=com" read by * none
      
    13. 導入 changes.ldif 檔案到 LDAP Server 中:
      #ldapmodify -Y EXTERNAL -H ldapi:/// -f /etc/openldap/changes.ldif
      
    14. 可開始建立所須網域的 ldif 檔案:
      #vim /etc/openldap/base.ldif
      dn: dc=example,dc=com
      dc: example
      objectClass: top
      objectClass: domain
      
      dn: ou=People,dc=example,dc=com
      ou: People
      objectClass: top
      objectClass: organizationalUnit
      
      dn: ou=Group,dc=example,dc=com
      ou: Group
      objectClass: top
      objectClass: organizationalUnit
      
    15. 導入 base.ldif 檔案到 LDAP Server 中:
      #ldapadd -x -w redhat -D cn=Manager,dc=example,dc=com -f /etc/openldap/base.ldif
      
    16. 增加兩個系統使用者帳號來測試一下:
      # mkdir /home/guests
      # useradd -d /home/guests/ldapuser01 ldapuser01
      # passwd ldapuser01
      # useradd -d /home/guests/ldapuser02 ldapuser02
      # passwd ldapuser02
      
    17. 編寫 migrate_common.ph內容,將系統上的使用者,導入到 LDAP Server 中:
      #vim /usr/share/migrationtools/migrate_common.ph
      $DEFAULT_MAIL_DOMAIN = "example.com";
      $DEFAULT_BASE = "dc=example,dc=com";
      
    18. 在LDAP Server 中,建立目前的使用者與群組:
      # grep ":10[0-9][0-9]" /etc/passwd > passwd
      # ./migrate_passwd.pl passwd users.ldif
      # ldapadd -x -w redhat -D cn=Manager,dc=example,dc=com -f users.ldif
      # grep ":10[0-9][0-9]" /etc/group > group
      # ./migrate_group.pl group groups.ldif
      # ldapadd -x -w redhat -D cn=Manager,dc=example,dc=com -f groups.ldif
      
    19. 測試目前的使用者 ldapuser01:
      # ldapsearch -x cn=ldapuser01 -b dc=example,dc=com
      
    20. 可加入系統記錄服務:
      #vim /etc/rsyslog.conf
      local4.* /var/log/ldap.log
      
      (重新啟動系統記錄服務:)
      #systemctl restart rsyslog
      
    參考資料網址:
    1. https://www.certdepot.net/rhel7-configure-ldap-directory-service-user-connection/
    2. http://www.server-world.info/en/note?os=CentOS_7&p=openldap
    3. http://jamyy.us.to/blog/2014/09/6704.html
    4. http://yu-li-liang.blogspot.tw/2014/04/linux-centos-ldap-server-24.html
    5. http://crashedbboy.blogspot.tw/2015/08/centos-7-open-ldap.html