Unix/Solaris10

Active Directory에 드디어 물리다

ForceCore 2007. 11. 18. 02:06

!!!!!!! LDAP client를 이용해 물리는 방법이 연구가 되어 완성 되었다.
삼바를 쓰지 않는 방법을 추천하는 바이다.

Solaris를 AD에 bind하려면 samba를 쓰는 것이 가장 편함.
하지만 기본 include된 samba는 솔라리스10 마케팅 팀이
광고하는 것과 달리, AD에 bind할 수 없다. -_-;;
그런 옵션을 걸지 않고 컴파일 했기 때문.
sunfreeware의 패키지도 그건 마찬가지.
http://forum.java.sun.com/thread.jspa?threadID=5073227: 여기서 그런 정보를 얻었다.

 

필요한 것
- 삼바 소스코드
- MIT Kerberos (역시 소스... 패키지가 없다. 게다가, 솔라리스에 딸려오는 것은 compile against할 lib이 제공되지 않음.)
- openssl
- openldap

 

Kerberos 컴파일
http://web.mit.edu/Kerberos/krb5-1.6/krb5-1.6.3/doc/krb5-install.html
소스를 받는다.
krb/src로 들어간다.

$ ./configure
$ make

면 충분하다. configure가 오래 돈다 -_-;; make도 오래 돈다 -_-;;;
하지만 오류는 없었다 (솔라리스에서 이런 큰 시스템이 잘 컴파일 되다니 웬일)


# make install

 

하면 끝.
/usr/local/lib
/usr/local/bin에 필요한 파일들이 설치될 것이다.

 

/krb5/src/config-files/krb5.conf를 /etc/krb5.conf로 복사.

그리고 설정을 한다.

 

http://www.enterprisenetworkingplanet.com/netos/article.php/3487081

[libdefaults]
    default_realm = YYY.YYY.AC.KR

[realms]
    XXX.YYY.AC.KR = {
        kdc = YYY.yyy.ac.kr
    }

[domain_realm]
    .xxx.yyy.ac.kr = XXX.yyy.AC.KR
    xxx.yyy.ac.kr = XXX.YYY.AC.KR

 

/etc/resolv.conf를 수정해서
primary domain controller를 dns 서버로 쓰게 할 것.

 

$ kinitAdministrator@YYY.AC.KR

 

을 테스트.
성공해야만 함 -_-...

 

삼바 컴파일
http://us4.samba.org/samba/docs/man/Samba-HOWTO-Collection/compiling.html
소스코드를 받는다.
samba/source로 들어간다.
... autoconf 유틸이 설치되어 있어야 하는데... m4도 필요함.

$ ./autogen.sh

 

실행. 좀 오래 걸림.
./configure 만 해도 될 것 같지만,


$ ./configure --with-ads --with-ldap --with-winbind --with-sambaconfdir=/etc/samba --with-logdir=/var/log/samba --with-pam

를 했음.
오래 걸린다 -_-;;
필자는 아무 문제 없이 되었다.

 

include/config.h를 체크해보라.

#define HAVE_KRB5 1
#define HAVE_LDAP 1

이 있으면 성공.

 

$ make

오래걸리는데... 과연?
성공한듯. warning이 많이 나오기는 했다.

 

# make install
# make installbin
# make installman

 

이번에 한 작업은 큰 컴파일이 많았으나 모두 잘 되었다.
웬일이람 ㅋㅋ

 

이제 설정.
samba/examples 에 보면 smb.conf.default가 들어있다. 이를
/etc/samba에 복사한다.

(* configure때 옵션을 넣지 않았다면,/usr/local/samba/lib/smb.conf를 읽게됨.)

 

/etc/services
netbios-ssn     139/tcp
netbios-ns 137/udp
가 있는지 체크.

 

/etc/init.d/samba를 수정하든, 백업하고 새로 만들든지 해서,

case "$1" in
start)
    [ -f /etc/samba/smb.conf ] || exit 0

    /usr/local/samba/sbin/smbd -D
    /usr/local/samba/sbin/nmbd -D
    /usr/local/samba/sbin/winbindd -B
    ;;
stop)
    pkill smbd
    pkill nmbd
    pkill winbindd
    ;;
*)
    echo "Usage: $0 { start | stop }"
    exit 1
    ;;
esac
exit 0

내용을 위와 같이 만든다.

 

그리고 이렇게 AD에는 bind함...
솔라리스엔 ldap을 안 쓰고 winbind를 쓰는게 속 편하다 ㅡ,.ㅡhttp://us4.samba.org/samba/docs/man/Samba-HOWTO-Collection/winbind.html

 

libnss_winbind.so를 복사하고 소프트링크도 여러 곳에 만들어야 함.
root# cp ../samba/source/nsswitch/libnss_winbind.so /lib
root# ln -s /lib/libnss_winbind.so /lib/libnss_winbind.so.2
root# ln -s /usr/lib/libnss_winbind.so /usr/lib/libnss_winbind.so.1
root# ln -s /usr/lib/libnss_winbind.so /usr/lib/nss_winbind.so.1
root# ln -s /usr/lib/libnss_winbind.so /usr/lib/nss_winbind.so.2

 

/etc/nsswitch.conf 수정:
passwd:     files winbind
group:      files winbind

 

smb.conf 수정: 필자의 경우임.
[global]
idmap uid = 10000000-999999999
idmap gid = 502-5000
winbind separator = \
winbind enum users = yes
winbind enum groups = yes
template homedir = /export/home/%D/%U
template shell = /bin/bash
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
# XXX.yyy.ac.kr도메인인 도메인 컨트롤러.
   workgroup = XXX

# Security mode. Defines in which mode Samba will operate. Possible
# values are share, user, server, domain and ads. Most people will want
# user level security. See the Samba-HOWTO-Collection for details.
   security = ADS


kerberos와 samba를 모두 configure했으면 AD에 join시킬 차례!

 

# ./net ads join -U Administrator

를 시도해보고,
안 되면


# ./net ads join -U Administrator -d 10

으로 verbose한 출력을 보라.

필자는 kinit만 성공하고 net join ads는 실패.
왜!!!


  kerberos_kinit_passwordAdministrator@XXX.YYY.AC.KRfailed: Preauthentication failed
Failed to join domain: Logon failure

이런 에러가 나온다.

아래처럼 입력해보라.

그냥 버그인듯 -_-


# net ads join -U Administrator%비번


은 반응이 좀 있음.

그 다음에 나온 에러는
Failed to set servicePrincipalNames
에러인데...

 

/etc/hosts를 수정해서...

123.100.121.121 zzz loghost

이렇게만 되어 있을 것이다. 대문자 서버 이름 ZZZ, 그리고 FQDN ZZZ.YYY.AC.KR도 적는다.
123.100.121.121 zzz loghost ZZZ ZZZ.YYY.AC.KR

ZZZ는 AD에 물리고 싶은 서버 이름이다.


을 추가하니까 성공했음.
joined 뭐시기 to realm 거시기
이런 메시지가 뜰 것이다.

 

$ getent passwd

를 하면 이제 AD의 유저가 떠야 할 것이다.

 

하지만 도메인 유저가 아직 SSH같은 것으로 로그인 할 수는 없음.

 

pam winbind 컴파일이 문제.
어쩌구/source 에서

$ make nsswitch

를 하면 된다...

 

필자는 이런 에러가 났다:
nsswitch/pam_winbind.c:2009: error: `PAM_PRELIM_CHECK' undeclared (first use in this function)
nsswitch/pam_winbind.c:2009: error: (Each undeclared identifier is reported only once
nsswitch/pam_winbind.c:2009: error: for each function it appears in.)
nsswitch/pam_winbind.c:2055: error: `PAM_UPDATE_AUTHTOK' undeclared (first use in this function)

 

으음...

글쎄... autoconf와 configure를 다시 하고 하니까 되었다.

source/bin/pam_winbind.so 가 생김.
이를 /usr/lib/security로 복사.

 

/etc/pam.conf를 수정할 차례.
적절히 수정 후 적절히 홈디렉토리 만드는걸 추가.

 

pam.conf

smb.conf

krb5.conf

를 zip으로 묶어 첨부파일로 첨부한다.