samba和openldap結合實戰(轉)
samba和openldap結合實戰(轉)[@more@]RedHat Enterprise Linux Server 4.2 + OpenLDAP + LDAP Browser/Editor + Samba + Squid + Postfix + Antivir-Mailgate + EGroupWare作者:Fandy電子郵箱:cbbc@163.com、cbbc@avl.com.cnQQ號碼:332018422建立日期:2006年01月16日,最後修改日期:2006年03月02日版權說明:本文章的內容歸作者版權所有,同時也接受大家的轉貼,但一定要儲存作者資訊和出處,多謝!因為軟體版權和費用的問題,一值是公司凝難問題(我們是一家中小型企業,沒有那麼多錢來投資和購買軟體license費用)。經過公司高層領導的決定,公司準備將所有Microsoft伺服器作業系統更改為RedHat Enterprise Server 4.2伺服器作業系統!公司高層領導對新網路改造要求也不高就是可以共享上網和印表機、公司郵件和使用者資料統一管理。在網路配置過程中遇到了許多不明白的問題,好在有google.com這個好朋友和得到“日京三子、Extmail、fjufirefox”等幾位Linux前輩的指導,才可以順利完成這一次網路改造任務,真的要好多謝幾位前輩的幫助,多謝!文章分為五大部分介紹實施情況:第一部分:OpenLDAP主機安裝RedHat Enterprise Linux Server 4.2系統過程;第二部分:DNS + OpenLDAP + Samba(PDC)+ LDAP Browser/Editor系統安裝和配置;第三部分:Squid系統安裝和配置;第四部分:Postfix + Dovecot + Antivir-Mailgate + MailScanner + EGroupWare系統安裝和配置;第五部分:客戶端Windows XP、Fedora加入Samba PDC和電子郵件正常收發,EGroupWare的使用介紹;Setp0、實現網路圖:Setp1、OpenLDAP主機安裝RedHat Enterprise Linux Server 4.2作業系統截圖:磁碟配置:裝置 型別 大小/ ext3 39911swap 1024網路基本配置:etho IP/Gateway:192.168.1.254/255.255.255.0主機名:ldap.easy.com閘道器:192.168.1.1主/次DNS:192.168.1.254/202.96.128.68防火牆基本配置:⊙ 無防火牆⊙ 是否啟用 SELinux:已禁用安裝方式的選項:⊙ 定製要安裝的軟體包(C)桌面選項:(√) X視窗系統 (選取全部)(√) GNOME桌面環境 (選取全部)應用程式選項:(√) 工程和科學 (選取預設)(√) 圖形化網際網路 (選取預設)(√) 基於文字的網際網路 (選取預設)(√) 辦公/生產率 (選取預設)伺服器選項:(√) 伺服器配置工具 (選取全部)(√) 全球資訊網伺服器 (選取全部)(√) Windows檔案伺服器 (選取全部)(√) DNS伺服器 (選取全部)開發選項:(√) 開發工具 (選擇全部)系統選項:(√) 管理工具 (選取預設)(√) 列印支援 (選取預設)雜項選項:全部不要選擇;OpenLDAP + Samba所需要的全部軟體包清單(包括:DNS、DB、OpenLDAP、Samba、Other):bind-9.2.4-2.i386.rpm bind-chroot-9.2.4-2.i386.rpmbind-devel-9.2.4-2.i386.rpm bind-libs-9.2.4-2.i386.rpmbind-utils-9.2.4-2.i386.rpmdb4-4.2.52-7.1.i386.rpm db4-utils-4.2.52-7.1.i386.rpmdb4-devel-4.2.52-7.1.i386.rpmopenldap-2.2.13-3.i386.rpm openldap-clients-2.2.13-3.i386.rpmopenldap-devel-2.2.13-3.i386.rpm openldap-servers-2.2.13-3.i386.rpmsamba-3.0.10-1.4E.2.i386.rpm samba-client-3.0.10-1.4E.2.i386.rpmsamba-common-3.0.10-1.4E.2.i386.rpm samba-swat-3.0.10-1.4E.2.i386.rpmsmbldap-tools-0.9.1-1.2.el4.rf.noarch.rpmperl-Crypt-SmbHash-0.02-1.2.el4.rf.noarch.rpm perl-Digest-SHA1-2.07-5.i386.rpmperl-LDAP-0.31-5.noarch.rpm perl-XML-SAX-0.12-7.noarch.rpmmod_authz_ldap-0.26-2.i386.rpm nss_ldap-226-6.i386.rpmSetp2、DNS詳細配置過程:修改/var/named/chroot/etc/named.conf檔案,新增以下內容如下:詳細內容:zone "easy.com" { #正解type master;file "/var/named/easy.com.hosts";};zone "1.168.192.in-addr.arpa" { #反解type master;file "/var/named/192.168.1.rev";};在/var/named/chroot/var/named/目錄建立正解easy.com.hosts檔案,檔案完整內容如下:詳細內容:$ttl 38400easy.com. IN SOA ldap.easy.com. fandy.easy.com. (113706312010800360060480038400 )easy.com. IN NS ldap.easy.com.easy.com. IN A 192.168.1.254ldap.easy.com IN A 192.168.1.254mail.easy.com. IN A 192.168.1.253mail.easy.com. IN MX 10 mail.easy.com在/var/named/chroot/var/named/目錄建立正解192.168.1.rev檔案,檔案完整內容如下::詳細內容:$ttl 384001.168.192.in-addr.arpa. IN SOA mail.easy.com. fandy.easy.com. (113706326810800360060480038400 )1.168.192.in-addr.arpa. IN NS ldap.easy.com.254.1.168.192.in-addr.arpa. IN PTR easy.com.253.1.168.192.in-addr.arpa. IN PTR mail.easy.com.254.1.168.192.in-addr.arpa. IN PTR ldap.easy.com.Setp3、OpenLDAP的詳細配置過程:在配置OpenLDAP前,先複製samba.schema檔案到/etc/openldap/schema/目錄下(新增ldap所需要的samba認證的資料檔案到schema目錄):詳細操作:# cp /usr/share/doc/samb-3.0.10/LDAP/samba.schema /etc/openldap/schema/-----------------------------------------------------------------------------------------------------------------------說明:請一定要複製samba.schema檔案到/etc/openldap/schema目錄下, 否則在啟動ldap時會出現以下的錯誤提示資訊:# service ldap start檢查 的配置檔案:slaptest: bad configuration file! [失敗]-----------------------------------------------------------------------------------------------------------------------修改/etc/openldap/目錄中的slapd.conf檔案,主要說明修改的關鍵部分,詳細內容如下:詳細配置內容:include /etc/openldap/schema/core.schemainclude /etc/openldap/schema/cosine.schemainclude /etc/openldap/schema/inetorgperson.schemainclude /etc/openldap/schema/nis.schema部分增加以下一行內容:include /etc/openldap/schema/samba.schemadatabase ldbm(定義ldap的資料庫型別)更改為:database bdbsuffix "dc=my-domain,dc=com" (定義ldap搜尋的域字尾)rootdn "cn=Manager,dc= my-domain,dc=com" (定義ldap的管理DN)更改為:suffix "dc=easy,dc=com"rootdn "cn=Manager,dc=easy,dc=com"# rootpw {crypt}ijFYNcSNctBYg (設定管理DN的密碼)更改為:rootpw {SSHA}zW6nrZ8Muho9GOl/nAk3grt4Xqq0ZpJi-----------------------------------------------------------------------------------------------------------------------說明:DN管理者密碼的製造過程:# slappasswd -h {SSHA} -s jinbiao{SSHA}zW6nrZ8Muho9GOl/nAk3grt4Xqq0ZpJi-----------------------------------------------------------------------------------------------------------------------繼續slapd.conf檔案內容:詳細配置內容:index objectClass eq,presindex ou,cn,mail,surname,givenname eq,pres,subindex uidNumber,gidNumber,loginShell eq,presindex uid,memberUid eq,pres,subindex nisMapName,nisMapEntry eq,pres,sub更改為:index objectClass,uidNumber,gidNumber eqindex cn,sn,uid,displayName pres,sub,eqindex memberUid,mail,givenname eq,subinitialindex sambaSID,sambaPrimaryGroupSID,sambaDomainName eqaccess to attrs=userPassword,sambaLMPassword,sambaNTPasswordby self writeby anonymous authby * noneaccess to *by * read-----------------------------------------------------------------------------------------------------------------------在slapd.conf檔案最後部分新增的內容,作用為定義ldap的訪問許可權(注意書寫的格式,因為作者就是因為這個問題浪費了不少的時間和感情啦!-----------------------------------------------------------------------------------------------------------------------修改/etc/openldap/ldap.conf檔案內容,主要說明修改的關鍵部分:詳細配置內容:BASE dc=example,dc=com (更改ldap搜尋的域字尾)更改為:BASE dc=easy,dc=comTLS_CACERTDIR /etc/openldap/cacerts(不使用TLS服務專案)更改為:# TLS_CACERTDIR /etc/openldap/cacerts啟動OpenLDAP伺服器專案,詳細操作如下:詳細操作:# service ldap start檢查 slapd 的配置檔案:config file testing succeeded啟動 slapd: [ 確定 ]配置linux系統使用ldap進認證過程:詳細操作:# setup選擇一種工具專案中選擇:驗證配置,然後按“執行工具”鍵;使用者資訊專案中點選“快取資訊”、“使用LDAP”;驗證專案中點選“使用MD5口令”、“使用遮蔽口令”、“使用LDAP驗證”;然後按“下一步”鍵;LDAP設定:[ ] 使用TLS (不要點選);伺服器:127.0.0.1 (按預設地址)基點 DN:dc=easy,dc=com (更改為:dc=easy,dc=com)然後按“確定”鍵:系統自動執行過程如下:setsebool: SELinux is disabled.停止 nscd: [ 失敗 ]啟動 nscd: [ 確定 ]執行後以上的操作後,將後回到“選擇一種工具”介面,按“退出”鍵完成所有ldap進認證過程。修改/etc/openldap/ldap.conf檔案內容,主要說明修改的關鍵部分:詳細配置內容:TLS_CACERTDIR /etc/openldap/cacerts更改為:# TLS_CACERTDIR /etc/openldap/cacerts修改/etc/ ldap.conf檔案內容,主要說明修改的關鍵部分:詳細配置內容:#krb5_ccname FILE:/etc/.ldapcache新增以下內容:#krb5_ccname FILE:/etc/.ldapcachenss_base_passwd ou=Users,dc=easy,dc=com?onenss_base_passwd ou=Computers,dc=easy,dc=com?onenss_base_shadow ou=Users,dc=easy,dc=com?onenss_base_group ou=Groups,dc=easy,dc=com?oneTLS_CACERTDIR /etc/openldap/cacerts更改為:# TLS_CACERTDIR /etc/openldap/cacerts重新啟動OpenLDAP伺服器專案,詳細操作如下:詳細操作:# service ldap restart停止 slapd: [ 確定 ]檢查 slapd 的配置檔案:config file testing succeeded啟動 slapd: [ 確定 ]檢視OpenLDAP伺服器埠是否被監聽,詳細操作如下:詳細操作:# netstat -an |grep 389tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTENtcp 0 0 :::389 :::* LISTENSamba的詳細配置過程:在配置smb.conf前,先備份原smb.conf檔案:詳細操作:# cp /etc/samba/smb.conf /etc/samba/backup_smb.confSamba的主要配置檔案/etc/samba/smb.conf,其實系統中存有一個實際的例子配置檔案可提供參考,只要更換成例子檔案和按照自己的實際情況做一定的修改就可供使用:詳細操作:# cp /usr/share/doc/smbldap-tools-0.9.1/smb.conf /etc/samba/cp:是否覆蓋‘/etc/samba/smb.conf’? y修改/etc/samba/smb.conf檔案,以下為完整檔案的詳細內容::詳細配置內容:############################## Global parameters############################[global]workgroup = easy-pdcnetbios name = PDCserver string = Samba Server %vlog file = /var/log/samba/log.%msecurity = userencrypt passwords = Yesobey pam restrictions = Noldap passwd sync = Yeslog level = 3syslog = 0max log size = 100000time server = Yessocket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192mangling method = hash2Dos charset = UTF-8Unix charset = UTF-8logon script = %U.batlogon drive = H:domain logons = Yesos level = 65preferred master = Yesdomain master = Yes繼續smb.conf檔案內容:詳細配置內容:passdb backend = ldapsam:ldap://127.0.0.1/ldap admin dn = cn=Manager,dc=easy,dc=comldap suffix = dc=easy,dc=comldap group suffix = ou=Groupsldap user suffix = ou=Usersldap machine suffix = ou=Computersldap ssl = offldap delete dn = Yesadd user script = /sbin/smbldap-useradd -m "%u"add machine script = /sbin/smbldap-useradd -t 0 -w "%u"add group script = /sbin/smbldap-groupadd -p "%g"add user to group script = /sbin/smbldap-groupmod -m "%u" "%g"delete user from group script = /sbin/smbldap-groupmod -x "%u" "%g"set primary group script = /sbin/smbldap-usermod -g '%g' '%u'############################## Homes parameters ############################[homes]comment = repertoire de %U, %ubrowseable = nowriteable = yesread only = noforce create mode = 0700create mode = 0700force directory mode = 0700directory mode = 700############################# Netlogone parameters ##########################[netlogon]path = /home/netlogon/browseable = Noread only = yes############################# Public parameters ##########################[public]comment = Public Directorypath = /home/public/browseable = Nowritable = yesguest ok = yescreate mask = 0777-----------------------------------------------------------------------------------------------------------------------特別提示:在網上有一些文章介紹可以實現自動建立計算機帳號的方法,不知道可否正常使用,小弟沒有試過!操作如下在smb.conf檔案的[global]里加入以下內容(注:適合Samba 3.0版以上):add machind script = /usr/sbin/useradd –d /dev/null –g 100 –s /bin/false –M %u-----------------------------------------------------------------------------------------------------------------------建立目錄和更改目錄屬性操作:詳細操作:# mkdir /home/netlogon# mkdir /home/public啟動Samba服務專案:詳細操作:# service smb start啟動 SMB 服務: [ 確定 ]啟動 NMB 服務: [ 確定 ]新增Samba admin dn的ldap管理密碼(注意密碼要和您openldap的rootdn密碼要一致啊):詳細操作:# smbpasswd -w jinbiaoSetting stored password for "cn=Manager,dc=easy,dc=com" in secrets.tdb使用testparm命令來測試Samba伺服器是否正常啟動:詳細操作:# testparmLoad smb config files from /etc/samba/smb.confProcessing section "[homes]"Processing section "[netlogon]"Processing section "[public]"Loaded services file OK.Server role: ROLE_DOMAIN_PDCPress enter to see a dump of your service definitionsSambldap的配置使用過程:詳細操作:# cd /usr/share/doc/smbldap-tools-0.9.1/# ./configure.pl-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-smbldap-tools script configuration-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=Before starting, check. if your samba controller is up and running.. if the domain SID is defined (you can get it with the 'net getlocalsid'). you can leave the configuration using the Crtl-c key combination. empty value can be set with the "." character-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-Looking for configuration files...Samba Configuration File Path [/etc/samba/smb.conf] >The default directory in which the smbldap configuration files are stored is shown.If you need to change this, enter the full directory path, then press enter to continue.Smbldap-tools Configuration Directory Path [/etc/smbldap-tools/] >-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=Let's start configuring the smbldap-tools scripts .... workgroup name: name of the domain Samba act as a PDCworkgroup name [easy-pdc] >. netbios name: netbios name of the samba controlernetbios name [PDC] >. logon drive: local path to which the home directory will be connected (for NT Workstations). Ex: 'H:'logon drive [H:] >. logon home: home directory location (for Win95/98 or NT Workstation).(use %U as username) Ex:'PDC\%U'logon home (press the "." character if you don't want homeDirectory) [PDC\%U] >. logon path: directory where roaming profiles are stored. Ex:'PDCprofiles\%U'logon path (press the "." character if you don't want roaming profile) [PDCprofiles\%U] > . (輸入“.”). home directory prefix (use %U as username) [/home/%U] >. default users' homeDirectory mode [700] >. default user netlogon script (use %U as username) [%U.bat] >default password validation time (time in days) [45] >. ldap suffix [dc=easy,dc=com] >. ldap group suffix [ou=Groups] >. ldap user suffix [ou=Users] >繼續smb.conf檔案內容:詳細配置內容:. ldap machine suffix [ou=Computers] >. Idmap suffix [ou=Idmap] >. sambaUnixIdPooldn: object where you want to store the next uidNumberand gidNumber available for new users and groupssambaUnixIdPooldn object (relative to ${suffix}) [sambaDomainName=easy-pdc] >. ldap master server: IP adress or DNS name of the master (writable) ldap serverldap master server [127.0.0.1] >. ldap master port [389] >. ldap master bind dn [cn=Manager,dc=easy,dc=com] >. ldap master bind password [] > jinbiao (Samba admin dn的ldap管理密碼). ldap slave server: IP adress or DNS name of the slave ldap server: can also be the master oneldap slave server [127.0.0.1] >. ldap slave port [389] >. ldap slave bind dn [cn=Manager,dc=easy,dc=com] >. ldap slave bind password [] > jinbiao (Samba admin dn的ldap管理密碼). ldap tls support (1/0) [0] >. SID for domain easy-pdc: SID of the domain (can be obtained with 'net getlocalsid PDC')SID for domain easy-pdc [S-1-5-21-2425048407-535062381-2029233160] >. unix password encryption: encryption used for unix passwordsunix password encryption (CRYPT, MD5, SMD5, SSHA, SHA) [SSHA] >. default user gidNumber [513] >. default computer gidNumber [515] >. default login shell [/bin/bash] >. default skeleton directory [/etc/skel] >. default domain name to append to mail adress [] > easy.com-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=backup old configuration files:/etc/smbldap-tools/smbldap.conf->/etc/smbldap-tools/smbldap.conf.old/etc/smbldap-tools/smbldap_bind.conf->/etc/smbldap-tools/smbldap_bind.conf.oldwriting new configuration file:/etc/smbldap-tools/smbldap.conf done./etc/smbldap-tools/smbldap_bind.conf done.-----------------------------------------------------------------------------------------------------------------------說明:檢查/etc/smbldap-tools/目錄內的smbldap_bind.conf檔案以下內容要一致:slaveDN=″cn=Manager,dc=easy,dc=com″slavePW =″jinbiao″masterDN=″cn=Manager,dc=easy,dc=com″masterPW “jinbiao”-----------------------------------------------------------------------------------------------------------------------使用smbldap-populate命令初始化使用者服務資料庫:詳細操作:# smbldap-populatePopulating LDAP directory for domain easy-pdc (S-1-5-21-810223790-3119279897-2165375470)(using builtin directory structure)adding new entry: dc=easy,dc=comadding new entry: ou=Users,dc=easy,dc=comadding new entry: ou=Groups,dc=easy,dc=comadding new entry: ou=Computers,dc=easy,dc=comadding new entry: ou=Idmap,dc=easy,dc=comadding new entry: uid=root,ou=Users,dc=easy,dc=comadding new entry: uid=nobody,ou=Users,dc=easy,dc=comadding new entry: cn=Domain Admins,ou=Groups,dc=easy,dc=comadding new entry: cn=Domain Users,ou=Groups,dc=easy,dc=comadding new entry: cn=Domain Guests,ou=Groups,dc=easy,dc=comadding new entry: cn=Domain Computers,ou=Groups,dc=easy,dc=comadding new entry: cn=Administrators,ou=Groups,dc=easy,dc=comadding new entry: cn=Account Operators,ou=Groups,dc=easy,dc=comadding new entry: cn=Print Operators,ou=Groups,dc=easy,dc=comadding new entry: cn=Backup Operators,ou=Groups,dc=easy,dc=comadding new entry: cn=Replicators,ou=Groups,dc=easy,dc=comadding new entry: sambaDomainName=easy-pdc,dc=easy,dc=comPlease provide a password for the domain root:Changing password for rootNew password : jinbiao (admin的ldap管理密碼)Retype new password : jinbiao (admin的ldap管理密碼)檢視Samba的SID編號:詳細操作:# net getlocalsidSID for domain EASY-PDC is: S-1-5-21-810223790-3119279897-2165375470為Samba新增使用者和計算機名:詳細操作:# smbldap-useradd -a user1 (新增一個samba帳號)# smbldap-useradd -a -m user2 (新增一個samba帳號並建立主目錄)# smbldap-useradd -m user3 (新增一個系統使用者帳號並建立主目錄)# smbldap-useradd -w winxp$ (新增一個域計算機帳號)更改user2帳號的密碼:詳細操作:# smbldap-passwd user2Changing password for user2New password : 123456 (使用者密碼)Retype new password : 123456 (確認使用者密碼)新增user2帳號的資訊:詳細操作:# smbldap-userinfo user2Changing the user information for user2Enter the new value, or press ENTER for the defaultUser Shell [/bin/bash]: /bin/shFull Name [System User]: fan jin biaoRoom Number []: 4873Work Phone []: 013060677004Home Phone []: 82-020-84680605Other []: ha ha!LDAP updated檢視user2帳號的資訊:詳細操作:# smbldap-usershow user2dn: uid=user2,ou=Users,dc=easy,dc=comobjectClass: top,inetOrgPerson,posixAccount,shadowAccount,sambaSamAccountuid: user2uidNumber: 1000gidNumber: 513homeDirectory: /home/user2description: System UsersambaLogonTime: 0sambaLogoffTime: 2147483647sambaKickoffTime: 2147483647sambaPwdCanChange: 0displayName: System UsersambaSID: S-1-5-21-2547670411-3484865238-2904186615-3000sambaPrimaryGroupSID: S-1-5-21-2547670411-3484865238-2904186615-513sambaLogonScript: user2.batsambaHomePath: PDCuser2sambaHomeDrive: H:sambaLMPassword: 15881AE64C222524AAD3B435B51404EEsambaAcctFlags: [U]sambaNTPassword: D577561A7CF0233733F6EA39BB596996sambaPwdLastSet: 1138015107sambaPwdMustChange: 1141903107userPassword: {SSHA}lSYoTrxEsxdfnMgCmxT8d72xKgdUZTVVgecos: fan jin biao,4873,013060677004,82-020-84680605,ha ha!cn: fan jin biaosn: biaogivenName: fan jinroomNumber: 4873telephoneNumber: 013060677004homePhone: 82-020-84680605loginShell: /bin/shSamba使用者登陸除錯說明:使用user2帳號登陸PDC伺服器:詳細操作:# smbclient -L 192.168.1.254 -U user2Password:Domain=[EASY-PDC] OS=[Unix] Server=[Samba 3.0.10-1.4E.2]Sharename Type Comment--------- ---- -------IPC$ IPC IPC Service (Samba Server 3.0.10-1.4E.2)ADMIN$ IPC IPC Service (Samba Server 3.0.10-1.4E.2)user2 Disk repertoire de user2, user2Domain=[EASY-PDC] OS=[Unix] Server=[Samba 3.0.10-1.4E.2]Server Comment--------- -------PDC Samba Server 3.0.10-1.4E.2Workgroup Master--------- -------EASY-PDC PDC用ssh測試smbldap新增的使用者是否正確:詳細操作:# ssh user2@192.168.1.254The authenticity of host '192.168.1.254 (192.168.1.254)' can't be established.RSA key fingerprint is 37:32:c7:3f:b6:8c:d2:a6:be:8c:44:05:4c:5c:92:ed.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.1.254' (RSA) to the list of known hosts.user2@192.168.1.254's password:-sh-3.00$ id (輸入id,然後按Enter鍵,檢視自己的uid、gid、groups等資訊)uid=1000(user2) gid=513(Domain Users) groups=513(Domain Users)-sh-3.00$ exit (輸入exit,離開本次登陸)logoutConnection to 192.168.1.254 closed.再次檢視OpenLDAP伺服器埠是否被監聽,詳細操作如下:詳細操作:# netstat -an |grep 389tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:32805 127.0.0.1:389 ESTABLISHEDtcp 0 0 127.0.0.1:32811 127.0.0.1:389 TIME_WAITtcp 0 0 127.0.0.1:389 127.0.0.1:32805 ESTABLISHEDtcp 0 0 :::389 :::* LISTENSamba域建立Windows使用者登陸logon檔案(本例為建立user2使用者的user2.bat檔案):使用“文字編輯器”在/home/netlogon/目錄新建user2.tmp檔案,完整內容如下:詳細內容:net time PDC /set /yes (客戶端與伺服器的時間同步)net use T: PDCpublic (設定public目錄為T:盤)將tmp檔案轉換成bat檔案(因作業系統檔案格式的不同,所以要進行一些特殊的轉換工作):詳細內容:# cat –A user2.tmp | tr ‘$’ ‘
’ > user2.bat檢視user2.bat檔案轉換結果:詳細內容:# cat –A user2.batnet time PDC /set /yes^M$net use T: PDCpublic^M$Setp4、使用Clamav + Samba-Vscan查殺Samba伺服器內設定的共享資料夾內容:軟體包格式:clamav-db-0.86.2-1.2.el4.rf.i386.rpmclamav-0.86.2-1.2.el4.rf.i386.rpmclamav-devel-0.86.2-1.2.el4.rf.i386.rpmclamd-0.86.2-1.2.el4.rf.i386.rpmclamav-milter-0.86.2-1.2.el4.rf.i386.rpm軟體包的大小分別為(KB):2385KB、602KB、153KB、58KB 、66KB下載地址:軟體包格式: samba-vscan-clamav-0.3.6-1.i386.rpm軟體包的大小(KB):56KB下載地址:安裝Clamav軟體包:詳細操作:# clamav-db-0.86.2-1.2.el4.rf.i386.rpmwarning: clamav-db-0.86.2-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 1aa78495Preparing... ########################################### [100%]1:clamav-db ########################################### [100%]# clamav-0.86.2-1.2.el4.rf.i386.rpmwarning: clamav-0.86.2-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 1aa78495Preparing... ########################################### [100%]1:clamav ########################################### [100%]# clamav-devel-0.86.2-1.2.el4.rf.i386.rpmwarning: clamd-0.86.2-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 1aa78495Preparing... ########################################### [100%]1:clamd ########################################### [100%]# clamd-0.86.2-1.2.el4.rf.i386.rpmwarning: clamav-devel-0.86.2-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 1aa78495Preparing... ########################################### [100%]1:clamav-devel ########################################### [100%]# clamav-milter-0.86.2-1.2.el4.rf.i386.rpmwarning: clamav-milter-0.86.2-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 1aa78495Preparing... ########################################### [100%]1:clamav-milter ########################################### [100%]-----------------------------------------------------------------------------------------------------------------------特別提示:請嚴格按照以上的安裝順序來安裝Clamav軟體包,否則出現安裝不成功的情況!-----------------------------------------------------------------------------------------------------------------------安裝Samba-Vscan軟體包:詳細操作:# samba-vscan-clamav-0.3.6-1.i386.rpmwarning: samba-vscan-clamav-0.3.6-1.i386.rpm: V3 DSA signature: NOKEY, key ID 6cdf2cc1Preparing... ########################################### [100%]1:samba-vscan-clamav ########################################### [100%]升級病毒庫檔案:詳細操作:# freshclam –verboseCurrent working dir is /var/clamavMax retries == 3ClamAV update process started at Fri Jan 27 17:37:45 2006Querying current.cvd.clamav.netTTL: 900Software version from DNS: 0.88WARNING: Your ClamAV installation is OUTDATED!WARNING: Local version: 0.86.2 Recommended version: 0.88DON'T PANIC! Read main.cvd version from DNS: 35Retrieving Downloading main.cvd[*]main.cvd updated (version: 35, sigs: 41649, f-level: 6, builder: tkojm)WARNING: Your ClamAV installation is OUTDATED!WARNING: Current functionality level = 5, recommended = 6DON'T PANIC! Read daily.cvd version from DNS: 1252Retrieving Downloading daily.cvd[*]daily.cvd updated (version: 1252, sigs: 1513, f-level: 7, builder: diego)WARNING: Your ClamAV installation is OUTDATED!WARNING: Current functionality level = 5, recommended = 7DON'T PANIC! Read Database updated (43162 signatures) from db.cn.clamav.net (IP: 221.6.197.162)ERROR: Clamd was NOT notified: Can't connect to clamd on 127.0.0.1:3310connect(): Connection refusedFreeing option list...done修改/etc/samba/目錄中的smb.conf檔案中[global]配置部分加入以下內容,完整內容如下:詳細操作:############################## Global parameters############################[global]workgroup = easy-pdcnetbios name = PDCserver string = Samba Server %vlog file = /var/log/samba/log.%msecurity = userencrypt passwords = Yesobey pam restrictions = Noldap passwd sync = Yeslog level = 3syslog = 0max log size = 100000time server = Yessocket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192mangling method = hash2Dos charset = UTF-8Unix charset = UTF-8logon script = %U.batlogon drive = H:domain logons = Yesos level = 65preferred master = Yesdomain master = Yespassdb backend = ldapsam:ldap://127.0.0.1/ldap admin dn = cn=Manager,dc=easy,dc=comldap suffix = dc=easy,dc=comldap group suffix = ou=Groupsldap user suffix = ou=Usersldap machine suffix = ou=Computersldap ssl = offldap delete dn = Yesadd user script = /sbin/smbldap-useradd -m "%u"add machine script = /sbin/smbldap-useradd -t 0 -w "%u"add group script = /sbin/smbldap-groupadd -p "%g"add user to group script = /sbin/smbldap-groupmod -m "%u" "%g"delete user from group script = /sbin/smbldap-groupmod -x "%u" "%g"set primary group script = /sbin/smbldap-usermod -g '%g' '%u'vfs object = vscan-clamavvscan-oav: config-file = /etc/samba/vscan-clamav.conf修改修改/etc/samba/目錄中的vscan-clamav.conf檔案,主要說明修改的關鍵部分,詳細內容如下:詳細操作:infected file action = nothing (當找到感染的檔案是否發出”警告popup 視窗”給windows)更改為:infected file action = quarantine修改修改/etc/目錄中的clamd.conf檔案,主要說明修改的關鍵部分,詳細內容如下:詳細操作:TCPSocket 3310 (取消TCPSocket 3310)更改為:#TCPSocket 3310#LocalSocket /var/run/clamav/clamd.sock (clamd socket的位置)更改為:LocalSocket /var/run/clamav/clamd.sockUser clamav (更改操作使用者帳號)更改為:User root重新啟動Samba服務專案:詳細操作:# service smb restart關閉 SMB 服務: [ 確定 ]關閉 NMB 服務: [ 確定 ]啟動 SMB 服務: [ 確定 ]啟動 NMB 服務: [ 確定 ]啟動Samba服務專案:詳細操作:# service clamd startStarting Clam AntiVirus Daemon [ 確定 ]如果看到以下的訊息表現已經成功:詳細操作:# tail /var/log/messagesJan 27 17:56:10 ldap clamd[3218]: HTML support enabled.Jan 27 17:56:10 ldap clamd[3218]: Self checking every 1800 seconds.Jan 27 17:56:26 ldap smbd_vscan-clamav[3209]: samba-vscan (vscan-clamav 0.3.6) connected (Samba 3.0), (c) by Rainer Link, OpenAntiVirus.orgJan 27 17:56:26 ldap smbd_vscan-clamav[3209]: INFO: connect to service IPC$ by user nobodyJan 27 17:56:26 ldap smbd_vscan-clamav[3209]: INFO: disconnectedJan 27 17:56:26 ldap smbd_vscan-clamav[3209]: samba-vscan (vscan-clamav 0.3.6) connected (Samba 3.0), (c) by Rainer Link, OpenAntiVirus.orgJan 27 17:56:26 ldap smbd_vscan-clamav[3209]: INFO: connect to service IPC$ by user user2Jan 27 17:56:26 ldap smbd_vscan-clamav[3209]: samba-vscan (vscan-clamav 0.3.6) connected (Samba 3.0), (c) by Rainer Link, OpenAntiVirus.orgJan 27 17:56:26 ldap smbd_vscan-clamav[3209]: INFO: connect to service IPC$ by user nobodyJan 27 17:56:37 ldap smbd_vscan-clamav[3209]: INFO: disconnectedSetp5、使用LDAP Browser/Editor客戶端來管理OpenLdap中的資料:-----------------------------------------------------------------------------------------------------------------------特別提示:LDAP Browser/Editor軟體,需要在jdk 環境下才能執行。所以要安裝jdk-1.5.0_04軟體包才可以使LDAP Browser/Editor軟體正常工作!-----------------------------------------------------------------------------------------------------------------------軟體包格式:jdk-1_5_0_04-linux-i586-rpm.bin軟體包的大小(KB):45858KB下載地址:軟體包格式:Browser282b2.tar.gz軟體包的大小(KB):637KB下載地址:~gawojar/ldap/安裝LDAP Browser/Editor前,請先安裝jdk軟體包:詳細操作:# chmod 755 jdk-1_5_0_04-linux-i586-rpm.bin(更改檔案的執行許可權)# ./jdk-1_5_0_04-linux-i586-rpm.bin(編譯檔案,檢視版權說明過程)# rpm -ivh jdk-1_5_0_04-linux-i586.rpm(開始安裝檔案)Preparing... ############################################ [100%]package jdk-1.5.0_04-fcs is already installed修改/etc/目錄中的profile檔案(在profile檔案的最後面加入以下的資訊):詳細操作:JAVA_HOME=/usr/java/jdk1.5.0_04PATH=$JAVA_HOME/bin:$PATHCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport JAVA_HOME,PATH,CLASSPATH修改完/etc/目錄中的profile檔案後,重新啟動RedHat Enterprise Linux Server 4.2作業系統:詳細操作:# rebootLDAP Browser/Editor軟體包詳細安裝過程:詳細操作:# tar -zxvf Browser282b2.tar.gz -C /root/以下操作請回到桌面環境進行,點選工作列中“應用程式” → “檔案瀏覽器”;進入Browser282b2應用程式的解壓目錄,“/root/ldapbrowser”→ 雙擊“lbe.sh”執行程式;lbe.sh程式執行時,系統會出現一個提示 “執行還是顯示”資訊視窗內容如下:可點選“在終端中執行(T)”或者“執行(R)”兩按鍵中的其中之一;接著出現“Connect” → “Edit”按鍵;出現“Edit Session”資訊視窗,點選“Name”選擇框:Name:Easy-PDC (隨著輸入一個名稱)點選“Connection”選擇框:Host:127.0.01 (輸入ldap伺服器的主機地址);Port:389 (輸入訪問ldap伺服器的埠);Version:2 (選擇ldap伺服器的版本);Base DN:dc=easy,dc=com (輸入ldap伺服器的DN地址:dc=easy,dc=com);User DN:cn=Manager,dc=easy,dc=com (輸入管理ldap伺服器的使用者名稱);Password:jinbiao (輸入管理ldap伺服器的使用者密碼);點選“Save”按鍵;完成 “Edit Session”資訊視窗相關內容修改後 → 重新回到“Connect”資訊視窗 → 點選“Connect”按鍵;在配置 “Edit Session”資訊視窗相關內容時,沒有發生什麼修改錯誤的話。應就會跟小弟的系統一樣出現以下成功登入資訊視窗;到這為止,就完成Browser282b2軟體的所有配置工作!Setp9、Postfix主機安裝RedHat Enterprise Linux Server 4.2作業系統截圖:磁碟配置:裝置 型別 大小/ ext3 39911swap 1024網路基本配置:etho IP/Gateway:192.168.1.253/255.255.255.0主機名:mail.easy.com閘道器:192.168.1.1主/次DNS:192.168.1.254/192.168.1.253/202.96.128.68防火牆基本配置:⊙ 無防火牆⊙ 是否啟用 SELinux:已禁用安裝方式的選項:⊙ 定製要安裝的軟體包(C)桌面選項:(√) X視窗系統 (選取全部)(√) GNOME桌面環境 (選取全部)應用程式選項:(√) 工程和科學 (選取預設)(√) 圖形化網際網路 (選取預設)(√) 基於文字的網際網路 (選取預設)(√) 辦公/生產率 (選取預設)伺服器選項:(√) 伺服器配置工具 (選取全部)(√) 全球資訊網伺服器 (選取全部)(√) 郵件伺服器(自行選全部)(√) Windows檔案伺服器 (選取全部)(√) SQL資料庫 (選取全部)郵件伺服器的細節選項:(√) perl-Cyrus - Cyrus IMAP server utility Perl modules.(√) spamassassin - Spam filter for email which can be invoked from mail delivery age...開發選項:(√) 開發工具 (選擇全部)系統選項:(√) 管理工具 (選取預設)(√) 列印支援 (選取預設)雜項選項:全部不要選擇;Step6、Postfix軟體包安裝和配置過程:軟體包格式:postfix-2.2.5-1.mysql.sasl2.vda.rhel4.i386.rpm特別說明:本軟體包預設以支援LDAP、MySQL、SASL、VDA、TLS等功能;軟體包的大小(KB):3408KB下載地址:http://www.proficuous.com/postfix/4...ex_4_2.2.5.html安裝Postfix前,請先刪除系統安裝時所自帶的Sendmail軟體包:詳細操作:# service sendmail stop (停止sendmail系統的執行)# rpm -e sendmail --nodeps (從作業系統中刪除sendmail軟體包)Postfix軟體包詳細安裝過程:詳細操作:# rpm -ivh postfix-2.2.5-1.mysql.sasl2.vda.rhel4.i386.rpm (安裝postfix軟體包)Preparing... ########################################### [100%]1:postfix ########################################### [100%]查詢postfix使用者和所屬組的ID資料:詳細操作:# id postfix (查詢postfix使用者、所屬組的ID)uid=102(postfix) gid=103(postfix) groups=103(postfix),12(mail)使用者ID:102 所屬組ID:103使用postalias命令建立aliases.db檔案:詳細操作:# cd /etc/# postalias aliases (建立aliases.db檔案)Setp10、Windows XP SP2英文版作業系統加入Samba域詳細說明:在Windows XP SP2加入SMB域之前,請先執行以下的兩個註冊檔案:A、 WinXP_PlainPassword.regB、 WinXP_SignOrSeal.reg-----------------------------------------------------------------------------------------------------------------------說明:WinXP_PlainPassword.reg、WinXP_SignOrSeal.reg這兩個檔案可以在/usr/share/doc/samba-3.0.10/registry/目錄查詢到!-----------------------------------------------------------------------------------------------------------------------完成WinXP_PlainPassword.reg、WinXP_SignOrSeal.reg兩個註冊檔案的安裝工作後,點選“我的電腦” → “屬性”,出現“系統屬性”視窗;點選“計算機名” → “網路標識” → “更改(C)...”;出現“計算機名稱更改”屬性視窗:“隸屬於” → “域(D):” 輸入easy-pdc;(sambaDomain Namep定義域名);出現新的“計算機名更改”資訊視窗;請輸入有加入該域許可權的帳戶的名稱和密碼:使用者名稱(U):root密碼(P):jinbiao如果輸入的“計算機名(C):”和“域(D):”正確,經過一小段時間就會出現“歡迎加入easy-pdc域”的資訊視窗;關閉“歡迎加入easy-pdc域”的資訊視窗,按“確定”鍵,接著出現新的提示視窗“要使更改生效,必須重新啟動計算機”資訊視窗;關閉“要使更改生效,必須重新啟動計算機”資訊視窗。回到“系統屬性”視窗,按“確定”鍵,關閉“系統屬性”視窗;接著出現“系統設定改變”資訊視窗,提示“必須重新啟動計算機才能使新設定生效,想現在重新啟動計算機嗎?”,按“是(Y)”鍵,關閉“系統設定改變”資訊視窗;到這為止,就完成Windows XP SP2英文版作業系統加入Samba域的工作!完成重新啟動後,出現第一個資訊“Welcome to Windows”視窗:根據資訊提示同時按“Ctrl” + “Alt” + “Delete”三個按鍵,出現“Log On to Windows” 視窗:在“Log On to Windows” 視窗中點選“Options >>”按鍵;現在可以試一下輸入以下的使用者資訊登陸到Easy-PDC網域內:User name:user2Password:123456Log on to:EASY-PDC登陸作業系統後,桌面環境(一片空白);在桌面內,按“Mouse”右鍵,“Properties”;出現“Display Properties”視窗
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29514088/viewspace-1378784/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 結合實戰理解 Java 抽象類和介面Java抽象
- LDAP落地實戰(三):GitLab整合OpenLDAP認證LDAGitlab
- LDAP落地實戰(二):SVN整合OpenLDAP認證LDA
- LDAP落地實戰(四):Jenkins整合OpenLDAP認證LDAJenkins
- LDAP落地實戰(一):OpenLDAP部署及管理維護LDA
- Samba修改繫結埠和IP的方法Samba
- Kubernetes實戰總結 - DevOps實現(轉載)dev
- 結合實戰和原始碼來聊聊Java中的SPI機制?原始碼Java
- Flink-Kafka-Connector Flink結合Kafka實戰Kafka
- Linux與Windows共享檔案Samba(轉)LinuxWindowsSamba
- Samba服務的配置總結Samba
- Spring Boot和Apache Kafka結合實現錯誤處理,訊息轉換和事務支援?Spring BootApacheKafka
- web實戰:video結合canvas實現視訊線上截圖WebIDECanvas
- Vue3實戰系列:結合 Ant-Design-of-Vue 實踐 Composition APIVueAPI
- 【RAG 專案實戰 06】使用 LangChain 結合 Chainlit 實現文件問答LangChain
- BFS和Dijkstra結合
- Go專案實戰—引數繫結,型別轉換Go型別
- 使用hyperf結合DorisDB數倉的專案實戰體驗
- 【轉】微服務實戰微服務
- Django整合OpenLDAP認證DjangoLDA
- Go實戰最後一課:對於beego的基類封裝和結合Gin的設想Go封裝
- Flink SQL Client綜合實戰SQLclient
- TiDB 在轉轉的業務實戰TiDB
- 神結合!一招玩轉K8s和微服務治理K8S微服務
- Typescript結合React實踐TypeScriptReact
- 如何實現Samba檔案共享服務Samba
- Paradox管理團隊談新的產品戰略和結構轉型
- CGO實戰專案中常用的資料轉換和使用Go
- 反轉連結串列、合併連結串列、樹的子結構
- LlamaIndex RAG 和ReAct結合使用AIIndexReact
- `GitHub page` 和 `gitbook` 結合使用Github
- intervention/image和oss結合使用
- 1、實戰SSH埠轉發
- 實戰(二)輕鬆使用requests庫和beautifulsoup爬連結
- Apk瘦身實戰總結APK
- React hooks實戰總結ReactHook
- Git實戰命令總結Git
- Express 結合 Webpack 實現HMRwiExpressWeb
- Samba服務Samba