banner

[Rule] Rules  [Home] Main Forum  [Portal] Portal  
[Members] Member Listing  [Statistics] Statistics  [Search] Search  [Reading Room] Reading Room 
[Register] Register  
[Login] Loginhttp  | https  ]
 
Forum Index Thảo luận hệ điều hành *nix Hỏi cách dùng AD accounts để đăng nhập trên Linux server?  XML
  [Question]   Hỏi cách dùng AD accounts để đăng nhập trên Linux server? 09/06/2009 04:15:12 (+0700) | #1 | 183090
anbinh3333
Member

[Minus]    0    [Plus]
Joined: 08/06/2009 14:02:28
Messages: 10
Offline
[Profile] [PM]
Chào mọi người ! Hiện nay mình đang cấu hình Linux (CentOS ) join vô domain controller trên nền 2003 , mình đã join thành công ,sau đó mình tiến hành gõ lệnh wbinfo -u ,wbinfo -g thì thấy đc danh sách các member,group trong domain ! Sau đó mình tạo 1 user tên là test tren AD 2k3 , minh tiến hành log off khỏi user root và log on vao bằng test thì ko dc, ko biet mình có bị lỗi gì ko ! Mong mọi người hướng dẫn thêm ! Tks
Đây là file cấu hình smb.conf của mình !
# Global parameters
[global]
realm = LOC.COM

workgroup = LOC
#server string = locithcm %h %v //%v
server string = DATASHARE
# passdb backend =tdbsam
wins support = yes
wins server = 10.100.10.143
bind interfaces only = Yes
pam password change = Yes
passwd chat = *New*Password* %n\n *Re-enter*new*password* %n\n *Password*changed*
password server = LOC.COM
username map = /etc/samba/smbusers
unix password sync = Yes
log level = 1
syslog = 0
log file = /var/log/samba/%m
max log size = 50
smb ports = 139 445
name resolve order = wins bcast hosts
time server = Yes
winbind separator = +
winbind uid = 10000-20000
winbind gid = 10000-20000
# idmap uid= 10000-20000
# idmap gid= 10000-20000
winbind enum users = yes
winbind enum groups = yes
# them day
winbind use default domain = yes
winbind cache time =15
client schannel = no



# ------
#------------them day ---------
domain logons = yes
domain master = Yes
logon script = %U.bat
logon path= \\%L\Profiles\%U
wins support = Yes

#-----------------------
add user script = /usr/sbin/useradd -m %u
delete user script = /usr/sbin/userdel -r %u
add group script = /usr/sbin/groupadd %g
delete group script = /usr/sbin/groupdel %g
add user to group script = /usr/sbin/usermod -G %g %u
add machine script = /usr/sbin/useradd -s /bin/false -d /dev/null %u
logon script = scripts\%U.bat
logon home = \\%L\homes\%U
os level = 33
preferred master = No
domain master = No
security = ads
# security= ADS
# tam thoi tat domain logon
#domain logons =yes
utmp = Yes
veto oplock files = /*.doc/*.xls/*.mdb/
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
template shell = /bin/false
[homes]
comment = Home Directories
path= /home
valid users =%D+%S
read only = No
create mask = 0664
only user = Yes
browseable = Yes
writeable = yes
valid user= %D+%S

[printers]
comment = SMB Print Spool
path = /var/spool/samba
guest ok = Yes
printable = Yes
use client driver = Yes
default devmode = Yes
browseable =Yes

[netlogon]
comment = Network Logon Service
path = /var/lib/samba/netlogon
guest ok = Yes
locking = No
browseable = Yes


[public]
comment = Default share for group public
path = /public
writeable = yes
read only = No
browseable = Yes


[tinhoc]
comment = Noi luu tru phong tin hoc
path = /tinhoc
writeable = yes
read only = No
valid user =@LOC.COM +tinhoc
browseable = Yes

[Profiles]
comment= profile se luu o day
path = /home/profiles
browseable = yes
guest ok = Yes
force user = %U
valid user = %U "Domain Admins"
read only = no
profile acls = Yes
writeable = yes



[Up] [Print Copy]
  [Question]   Xin hỏi về Join Domain bị lỗi user trên linux 09/06/2009 04:48:05 (+0700) | #2 | 183094
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]
File /etc/nsswitch.conf của bạn có nội dung thế nào?

http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/winbind.html
Let's build on a great foundation!
[Up] [Print Copy]
  [Question]   Xin hỏi về Join Domain bị lỗi user trên linux 09/06/2009 21:54:19 (+0700) | #3 | 183129
anbinh3333
Member

[Minus]    0    [Plus]
Joined: 08/06/2009 14:02:28
Messages: 10
Offline
[Profile] [PM]
Tks bạn đã trả lời ! Đây là file nsswitch.conf của mình ! Theo mình thì file nsswitch.conf của mình ko bị lỗi gì cả vì
mình wbinfo -u thì thấy đc các member trên domain 2k3 ! Mình chỉ chưa hiểu tại sao sau khi đã join domain rùi thì
mình log off root ( CentOs ) ra rùi vào user do mình tạo( 2k3) thì ko dc

# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd: db files ldap nis
#shadow: db files ldap nis
#group: db files ldap nis

passwd: files winbind
shadow: files winbind
group: files winbind
hosts: files dns

bootparams: files
ethers: files
netmasks: files
networks: files
protocols: files winbind
rpc: files
services: files winbind
netgroup: files winbind

publickey: files
automount: files winbind
aliases: files
Mong mọi người hướng dẫn tiếp !

[Up] [Print Copy]
  [Question]   Xin hỏi về Join Domain bị lỗi user trên linux 09/06/2009 23:20:23 (+0700) | #4 | 183134
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]
getent passwd có trả về user nào trong AD không bạn?

Bạn thử xác thực với wbinfo -a username%password xem nó báo cáo gì?
Let's build on a great foundation!
[Up] [Print Copy]
  [Question]   Xin hỏi về Join Domain bị lỗi user trên linux 10/06/2009 03:52:41 (+0700) | #5 | 183147
anbinh3333
Member

[Minus]    0    [Plus]
Joined: 08/06/2009 14:02:28
Messages: 10
Offline
[Profile] [PM]
Chào ! khi mình gõ lệnh getent password thì hiện ra một loạt danh sách user bao gồm của AD 2k3 luôn , sau đó mình làm theo lời bạn gõ lệnh wbinfo -a Administrator% (pass admin trống ) thì trả về dòng lệnh sau :
plaintext password authentication succeeded
challenge/response password authentication succeeded
Tương tự với user test wbinfo -a test%123 thì cũng giống như trên ! Bạn còn ý nào khác ko để mình thử
[Up] [Print Copy]
  [Question]   Xin hỏi về Join Domain bị lỗi user trên linux 10/06/2009 07:17:32 (+0700) | #6 | 183160
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]

anbinh3333 wrote:
Chào ! khi mình gõ lệnh getent password thì hiện ra một loạt danh sách user bao gồm của AD 2k3 luôn , sau đó mình làm theo lời bạn gõ lệnh wbinfo -a Administrator% (pass admin trống ) thì trả về dòng lệnh sau :
plaintext password authentication succeeded
challenge/response password authentication succeeded
Tương tự với user test wbinfo -a test%123 thì cũng giống như trên ! Bạn còn ý nào khác ko để mình thử  

Theo mình hiểu thì:
- Kết quả như trên có nghĩa là user test (hoặc các AD account khác) đã có thể đăng nhập vào Samba server ngon rồi.
- Nhưng để user test có thể login trên chính máy Linux thì phải cần "một cái gì đó" đại loại như: PAM, Kerberos, LDAP, ... Mình nghĩ chỉnh /etc/pam.d/login là đơn giản nhất. Bạn http://www.onlamp.com/pub/a/onlamp/2008/04/01/step-by-step-using-samba-to-join-a-windows-domain.html.
Let's build on a great foundation!
[Up] [Print Copy]
  [Question]   Xin hỏi về Join Domain bị lỗi user trên linux 11/06/2009 06:12:59 (+0700) | #7 | 183210
anbinh3333
Member

[Minus]    0    [Plus]
Joined: 08/06/2009 14:02:28
Messages: 10
Offline
[Profile] [PM]
chán thiệt ! Mình cũng đã thử như cách của bạn rồi mà vẫn chưa đc ! Mình làm theo bước 8 trên trang web http://www.onlamp.com/pub/a/onlamp/2008/04/01/step-by-step-using-samba-to-join-a-windows-domain.html này của bạn mà vẫn chưa đc !
[Up] [Print Copy]
  [Question]   Xin hỏi về Join Domain bị lỗi user trên linux 11/06/2009 08:33:11 (+0700) | #8 | 183222
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]

anbinh3333 wrote:
chán thiệt ! Mình cũng đã thử như cách của bạn rồi mà vẫn chưa đc ! Mình làm theo bước 8 trên trang web http://www.onlamp.com/pub/a/onlamp/2008/04/01/step-by-step-using-samba-to-join-a-windows-domain.html này của bạn mà vẫn chưa đc !  

Đọc tiếp bước 9 và thử rồi đưa các thông tin liên quan lên đây.

anbinh3333 wrote:
Chào ! khi mình gõ lệnh getent password thì hiện ra một loạt danh sách user bao gồm của AD 2k3 luôn 

Cho xem thông tin liên quan đến user test?

- Username bạn thử dùng để login có đầy đủ dưới dạng DOMAIN+USER không?
- Đưa nội dung (tail -f sau mỗi lần login thôi nhé) tất cả các log files liên quan lên: /var/log/auth.log, /var/log/messages, /var/log/samba/winbindd.log, ... nói chung là tất tần tật những cái gì dính líu đến quá trình đăng nhập.


Let's build on a great foundation!
[Up] [Print Copy]
  [Question]   Xin hỏi về Join Domain bị lỗi user trên linux 19/07/2009 01:18:59 (+0700) | #9 | 186724
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]

anbinh3333 wrote:
Chào mọi người ! Hiện nay mình đang cấu hình Linux (CentOS ) join vô domain controller trên nền 2003 , mình đã join thành công ,sau đó mình tiến hành gõ lệnh wbinfo -u ,wbinfo -g thì thấy đc danh sách các member,group trong domain ! Sau đó mình tạo 1 user tên là test tren AD 2k3 , minh tiến hành log off khỏi user root và log on vao bằng test thì ko dc, ko biet mình có bị lỗi gì ko ! Mong mọi người hướng dẫn thêm ! Tks
...
 

--> Mình làm nốt bước này giúp bạn:

Coi như việc join Samba server vào Domain là xong rồi nhé, test các kiểu ngon lành rồi: wbinfo -u, wbinfo -g, wbinfo -t, getent passwd, getent group, ... Bây giờ chỉ còn cấu hình Kerberos và PAM nữa thôi.

Tại sao lại phải cấu hình Kerberos? À, Kerberos chỉ là một cách để Samba dựa vào đó mà xác thực các AD accounts thôi (lúc này Linux hoạt động như một Kerberos client đối với domain). Bạn có thể thử với OpenLDAP xem sao.

File cấu hình /etc/krb5.conf của mình như sau:
Code:
[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 default_realm = EXAMPLE.COM
 dns_lookup_realm = false
 dns_lookup_kdc = false
 ticket_lifetime = 24h
 forwardable = yes

[realms]
 EXAMPLE.COM = {
  kdc = IP.OF.THE.DC:88
  default_domain = example.com
 }

[domain_realm]
 .example.com = EXAMPLE.COM
 example.com = EXAMPLE.COM


Vậy tại sao phải cấu hình PAM? Câu trả lời là: nếu bạn muốn một dịch vụ nào đó sử dụng winbind cho việc xác thực thì bạn phải sửa file cấu hình của dịch vụ đó nằm trong /etc/pam.d. Giả sử ở đây mình muốn từ xa có thể ssh vào Linux server bằng các AD accounts, mình sửa file /etc/pam.d/sshd như sau:
Code:
auth            required        pam_nologin.so
auth            sufficient      pam_stack.so service=system-auth
auth            sufficient      pam_winbind.so

account         sufficient      pam_stack.so service=system-auth
account         sufficient      pam_wibind.so

password        required        pam_stack.so service=system-auth

session         required        pam_mkhomedir.so skel=/etc/skel umask=0022
session         sufficient      pam_stack.so service=system-auth
session         required        pam_limits.so
session         optional        pam_console.so


Dòng này:
Code:
session         required        pam_mkhomedir.so skel=/etc/skel umask=0022

có chức năng tự động tạo thư mục home trước khi user có thể login.

Kết hợp với dòng này template homedir = /home/%D/%U trong smb.conf, mỗi khi login lần đầu tiên với một AD account nào đó bạn sẽ nhìn thấy những dòng tương tự thế này:
Code:
$ ssh EXAMPLE.COM+quan.ta@ip.of.linux.server
EXAMPLE.COM+quan.ta@ip.of.linux.server's password: 
Creating directory '/home/EXAMPLE/quan.ta'.
Creating directory '/home/EXAMPLE/quan.ta/.mozilla'.
Creating directory '/home/EXAMPLE/quan.ta/.mozilla/plugins'.
Creating directory '/home/EXAMPLE/quan.ta/.mozilla/extensions'.
Last login: Sat Jul 18 11:58:20 2009 from x.x.x.x

Bạn chú ý định dạng của username nhé: DOMAIN+username, trừ phi trong smb.conf bạn có dòng này:
Code:
winbind use default domain = yes

Lúc đó bạn có thể dùng ngắn gọn là username.
Let's build on a great foundation!
[Up] [Print Copy]
  [Question]   Hỏi cách dùng AD accounts để đăng nhập trên Linux server? 24/07/2009 23:53:58 (+0700) | #10 | 187421
anbinh3333
Member

[Minus]    0    [Plus]
Joined: 08/06/2009 14:02:28
Messages: 10
Offline
[Profile] [PM]
Tks bạn đã hỗ trợ nhiều ! Mình sửa lại và làm đc rồi ! smilie
[Up] [Print Copy]
  [Question]   Hỏi cách dùng AD accounts để đăng nhập trên Linux server? 01/09/2009 13:52:00 (+0700) | #11 | 191693
[Avatar]
ORA2009
Member

[Minus]    0    [Plus]
Joined: 31/08/2009 11:04:02
Messages: 109
Offline
[Profile] [PM]
Hi all,

Mọi người có thể dùng Likewise Open

http://www.likewise.com/products/likewise_open/
[Up] [Print Copy]
  [Question]   Hỏi cách dùng AD accounts để đăng nhập trên Linux server? 18/05/2010 10:25:17 (+0700) | #12 | 211164
[Avatar]
rocklee44
Member

[Minus]    0    [Plus]
Joined: 24/07/2007 23:53:35
Messages: 53
Offline
[Profile] [PM]
Cho mình hỏi là quanta đã cấu hình thành công để domain user trên AD 2k3 login trên máy Linux được chưa ? Nếu rồi quanta có thể hướng dẫn cho mình không, mình làm hoài mà chưa được, winbind thì mình làm được rồi. Mình làm theo 2 link này :
http://www.interopsystems.com/LearningCenter/Native_LDAP_native_Kerberos_and_AD_services.htm
http://www.aput.net/~jheiss/krbldap/howto.html#kerbclient
Các file cấu hình :
Code:
/etc/ldap.conf
host 192.168.17.30
base dc=example,dc=com
ldap_version 3

binddn <a href="mailto:ldap@example.com">ldap@example.com</a>
bindpw P@ssw0rd

rootbinddn cn=manager,dc=example,dc=com

scope sub

timelimit 120
bind_timelimit 120
idle_timelimit 3600

# RFC 2307 (AD) mappings
nss_map_objectclass posixAccount user
nss_map_objectclass shadowAccount user
nss_map_attribute uid sAMAccountName
nss_map_attribute homeDirectory unixHomeDirectory
nss_map_attribute gecos cn
nss_map_attribute shadowLastChange pwdLastSet
nss_map_objectclass posixGroup group
nss_map_attribute uniqueMember member
pam_login_attribute sAMAccountName
pam_filter objectclass=User
pam_password ad


Code:
/etc/krb5.conf
[libdefaults]
	default_realm = EXAMPLE.COM

# The following krb5.conf variables are only for MIT Kerberos.
	krb4_config = /etc/krb.conf
	krb4_realms = /etc/krb.realms
	kdc_timesync = 1
	ccache_type = 4
	forwardable = true
	dns_lookup_realm = true
  	dns_lookup_kdc = true
	proxiable = true
	v4_instance_resolve = false
	v4_name_convert = {
		host = {
			rcmd = host
			ftp = ftp
		}
		plain = {
			something = something-else
		}
	}
	fcc-mit-ticketflags = true

[realms]
	EXAMPLE.COM = {
		kdc = chuong-2k3.example.com:88
		admin_server = chuong-2k3.example.com
		kpasswd_server = chuong-2k3.example.com:464
		kpasswd_protocol = SET_CHANGE 
		default_domain = example.com
	}
[domain_realm]
	.example.com = EXAMPLE.COM
	example.com = EXAMPLE.COM
[login]
	krb4_convert = true
	krb4_get_tickets = false


Code:
/etc/nsswitch.conf
passwd: files ldap
group: files ldap
shadow: files ldap

hosts:          files dns
networks:       files

protocols:      files ldap
services:       files ldap
ethers:         files
rpc:            files ldap

netgroup: nis files ldap


Code:
/etc/pam.d/login
auth        sufficient    /lib/security/pam_unix.so
auth        sufficient    /lib/security/pam_krb5.so use_first_pass
auth        sufficient    /lib/security/pam_ldap.so use_first_pass

account sufficient      pam_unix.so debug
account sufficient      pam_krb5.so debug
account sufficient      pam_ldap.so debug
account required        pam_permit.so

password    sufficient    /lib/security/pam_unix.so
password    sufficient    /lib/security/pam_krb5.so use_first_pass
password    sufficient    /lib/security/pam_ldap.so use_first_pass
password required       pam_deny.so


Đây là log khi login bằng domain account
Code:
login : u2
Password :
Insufficient credentials to access authentication data

/var/log/auth.log
May 18 10:34:39 chuong-ubuntu login[1352]: pam_unix(login:auth): check pass; user unknown
May 18 10:34:39 chuong-ubuntu login[1352]: pam_unix(login:auth): authentication failure; logname=LOGIN uid=0 euid=0 tty=/dev/tty1 ruser= rhost= 
May 18 10:34:39 chuong-ubuntu login[1352]: pam_unix(login:account): could not identify user (from getpwnam(u2))
May 18 10:34:39 chuong-ubuntu login[1352]: (pam_krb5): u2: pam_sm_acct_mgmt: entry (0x0)
May 18 10:34:39 chuong-ubuntu login[1352]: (pam_krb5): u2: retrieving principal from cache
May 18 10:34:39 chuong-ubuntu login[1352]: (pam_krb5): u2: pam_sm_acct_mgmt: exit (success)
May 18 10:34:39 chuong-ubuntu login[1352]: pam_unix(login:session): session opened for user u2 by LOGIN(uid=0)
May 18 10:34:39 chuong-ubuntu login[1352]: pam_mkhomedir(login:session): User unknown.
May 18 10:34:39 chuong-ubuntu login[1352]: (pam_krb5): u2: pam_sm_setcred: entry (0x2)
May 18 10:34:39 chuong-ubuntu login[1352]: (pam_krb5): u2: getpwnam failed for u2
May 18 10:34:39 chuong-ubuntu login[1352]: (pam_krb5): u2: pam_sm_setcred: exit (failure)
May 18 10:34:39 chuong-ubuntu login[1352]: Insufficient credentials to access authentication data

login : EXAMPLE\u2
Password :
Login incorrect
/var/log/auth.log
May 18 10:44:38 chuong-ubuntu login[1765]: pam_unix(login:auth): check pass; user unknown
May 18 10:44:38 chuong-ubuntu login[1765]: pam_unix(login:auth): authentication failure; logname=LOGIN uid=0 euid=0 tty=/dev/tty1 ruser= rhost= 
May 18 10:44:38 chuong-ubuntu login[1765]: pam_ldap: error trying to bind (Invalid credentials)
May 18 10:44:40 chuong-ubuntu login[1765]: FAILED LOGIN (1) on '/dev/tty1' FOR 'UNKNOWN', Permission denied

192.168.17.30 là AD 2003
Máy ubuntu cài các gói libpam-krb5, krb5-config, krb5-user, libpam_ldap, libnss_ldapd. 2 máy ping và phân giải được nhau. Thanks.
[Up] [Print Copy]
  [Question]   Hỏi cách dùng AD accounts để đăng nhập trên Linux server? 18/05/2010 10:44:39 (+0700) | #13 | 211165
[Avatar]
quanta
Moderator

Joined: 28/07/2006 14:44:21
Messages: 7265
Location: $ locate `whoami`
Offline
[Profile] [PM]
- wbinfo -u cho kết quả thế nào nhỉ?
- Bạn thử EXAMPLE.COM+u2 xem.
Let's build on a great foundation!
[Up] [Print Copy]
  [Question]   Hỏi cách dùng AD accounts để đăng nhập trên Linux server? 18/05/2010 12:50:54 (+0700) | #14 | 211170
[Avatar]
rocklee44
Member

[Minus]    0    [Plus]
Joined: 24/07/2007 23:53:35
Messages: 53
Offline
[Profile] [PM]
EXAMPLE.COM+u2 cũng báo Login incorrect
Mà bây giờ mình dùng LDAP + Kerberos thì đâu cần dùng winbind phải không ? Mình stop winbind rồi, nhưng trước đó mình đã dùng winbind chứng thực thành công, wbinfo -u cho thấy tất cả domain user và cũng cấu hình PAM dùng winbind, login bằng domain user được rồi.
Máy Ubuntu chỉ là client không cài samba server, ldapserver, kerberos server, mấy cài này AD 2003 làm, như vậy đúng không ?
[Up] [Print Copy]
  [Question]   Hỏi cách dùng AD accounts để đăng nhập trên Linux server? 05/09/2011 22:04:03 (+0700) | #15 | 246542
nhiennh
Member

[Minus]    0    [Plus]
Joined: 01/09/2011 13:28:46
Messages: 2
Offline
[Profile] [PM]
bạn ơi, mình làm theo hướng dẫn và đã tạo được profiles bằng ssh rổi, nhưng khi dùng máy win (xp, 2k3) thjf vẫn không tạo được, bạn hướng dẫn mình thêm phần đó đi, thanks
[Up] [Print Copy]
  [Question]   Hỏi cách dùng AD accounts để đăng nhập trên Linux server? 05/09/2011 22:06:21 (+0700) | #16 | 246543
nhiennh
Member

[Minus]    0    [Plus]
Joined: 01/09/2011 13:28:46
Messages: 2
Offline
[Profile] [PM]
với bạn hướng dẫn thêm cho mình phần tự map ổ đĩa mạng, khi user login vào, thanks
[Up] [Print Copy]
[digg] [delicious] [google] [yahoo] [technorati] [reddit] [stumbleupon]
Go to: 
 Users currently in here 
1 Anonymous

Powered by JForum - Extended by HVAOnline
 hvaonline.net  |  hvaforum.net  |  hvazone.net  |  hvanews.net  |  vnhacker.org
1999 - 2013 © v2012|0504|218|