配置Ubuntu使用ldap認證

來源:互聯網
上載者:User

配置Ubuntu使用ldap認證 將ubuntu配置為通過ldap認證,使其成為ldap client,本文實驗環境為ubuntu 12.04。  一、手工配置方式  1、軟體安裝: Java代碼  apt-get install ldap-utils libpam-ldap libnss-ldap nslcd   安裝過程中提示填寫ldap相關資訊:ldap server 地址,base dc等,資訊儲存在/etc/ldap.conf中,可通過dpkg-reconfigure ldap-auth-config重新設定,其中: ldap服務uri格式 ldap://ldapServerIP/search base:dc=my,dc=com,dc=cnroot ldap account:cn=admin,dc=my,dc=com,dc=cn 2、認證方式中添加ldap: Java代碼  root@ldapclient:~# auth-client-config -t nss -p lac_ldap   3、使認證通過後自動建立使用者家目錄: Java代碼  vi /etc/pam.d/common-session,追加內容:  session required pam_mkhomedir.so skel=/etc/skel umask=0022   4、配置開啟ldap認證方式 Java代碼  root@ldapclient:~# pam-auth-update   5、執行 Java代碼  update-rc.d nslcd enable   6、配置可在本機通過passwd更改使用者密碼: Java代碼  vi /etc/pam.d/common-password,除去其中的use_authtok參數   7、重啟相關服務: Java代碼  /etc/init.d/nscd restart   8、登陸或切換使用者時即通過ldap進行認證,如切換為ldap中的使用者manager: Java代碼  user1@ldapclient:~$ su - manager  Password:*****   Creating directory '/home/manager'.  manager@ldapclient:~$   參見http://askubuntu.com/questions/127389/how-to-configure-ubuntu-as-an-ldap-client  二、指令碼配置方式  如果需配置的機器很多,採用手工配置方式不太合適,可在待配置機器上運行如下shell指令碼進行自動化配置: C代碼  #!/bin/bash    #--------------------------------------------------------------------------------    #Ldap server地址及base DN  LDAP_SERVER_IP=192.168.1.100  BASE_DN='dc=my,dc=com,dc=cn'    #--------------------------------------------------------------------------------    #建立preseed檔案-軟體安裝自應答  touch debconf-ldap-preseed.txt  echo "ldap-auth-config    ldap-auth-config/ldapns/ldap-server    string    ldap://$LDAP_SERVER_IP" >> debconf-ldap-preseed.txt  echo "ldap-auth-config    ldap-auth-config/ldapns/base-dn    string    $BASE_DN" >> debconf-ldap-preseed.txt  echo "ldap-auth-config    ldap-auth-config/ldapns/ldap_version    select    3" >> debconf-ldap-preseed.txt  echo "ldap-auth-config    ldap-auth-config/dbrootlogin    boolean    false" >> debconf-ldap-preseed.txt  echo "ldap-auth-config    ldap-auth-config/dblogin    boolean    false" >> debconf-ldap-preseed.txt  echo "nslcd   nslcd/ldap-uris string  ldap://$LDAP_SERVER_IP" >> debconf-ldap-preseed.txt  echo "nslcd   nslcd/ldap-base string  $BASE_DN" >> debconf-ldap-preseed.txt    cat debconf-ldap-preseed.txt | debconf-set-selections    #安裝ldap client相關軟體  apt-get install -y ldap-utils libpam-ldap libnss-ldap nslcd    #認證方式中添加ldap  auth-client-config -t nss -p lac_ldap    #認證登入後自動建立使用者家目錄  echo "session required pam_mkhomedir.so skel=/etc/skel umask=0022" >> /etc/pam.d/common-session    #自啟動服務  update-rc.d nslcd enable    #可以在Host上通過passwd更改使用者密碼  cp /etc/pam.d/common-password /etc/pam.d/common-password.bak  sed -i 's/use_authtok//' /etc/pam.d/common-password    #使配置生效  /etc/init.d/nscd restart   

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.