[INFRA] OpenLDAP๊ณผ Client CentOS 7.9 ์—ฐ๋™ํ•˜๊ธฐ

2023. 1. 6. 03:11ใ†System ์ž‘์—…์‹ค/DevOps

728x90
๋ฐ˜์‘ํ˜•

 

 



๐Ÿ—‚ ๋ชฉ์ฐจ

โ— [INFRA] OpenLDAP๊ณผ LDAP Account Manager ์„ค์น˜ํ•˜๊ธฐ
โ— [INFRA] OpenLDAP๊ณผ Client CentOS 7.9 ์—ฐ๋™ํ•˜๊ธฐ
โ— [INFRA] Installation Keycloak of Ubuntu 22.04.01 LTS in Docker Container
โ— 

 

 

 

LDAP System Administration Paperback

COUPANG

www.coupang.com

"์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค."

 

 

 

๐Ÿš€ OpenLDAP๊ณผ Client ์—ฐ๋™ํ•˜๊ธฐ

    ๐Ÿ”ฝ  ๊ตฌ์„ฑ

        ๐Ÿ“ฆ ์ค€๋น„

OpenLDAP์„ ์„ค์น˜ํ•˜๊ณ , ์ด์ œ ๊ฐ Server๋ฅผ ์—ฐ๋™ํ•ด์„œ LDAP์„ ๋ณธ๊ฒฉ์ ์œผ๋กœ ์จ๋ณด๋ ค๊ณ  ํ•ด์š”.

cat /cat/redhat-release


์ฃผ๋‹ˆํ•˜๋ž‘์ด ์—ฐ๋™ํ•˜๊ณ ์ž ํ•˜๋Š” Client Server๋Š” CentOS 7.9๋ฅผ ์ด์šฉํ•˜๊ณ  ์žˆ์–ด์š”.

 

ldapsearch -x -b "ou=crew, dc=giggalpeople, dc=com"


์ตœ์ดˆ OpenLDAP Server์—์„œ ์œ„์™€ ๊ฐ™์ด ๋งŒ๋“ค์–ด ๋‘์—ˆ๋˜ testuser์ด๋ผ๋Š” ๊ณ„์ •์ด ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•ด ์ฃผ์—ˆ์–ด์š”.




์ด์ œ ๋‹ค์‹œ Client Server๋กœ ๋Œ์•„๊ฐ€ ์ž‘์—…์„ ํ•ด ๋ณผ๊ฒŒ์š”.

์ตœ์ดˆ Client Server์˜ FQDN(์ •๊ทœํ™”๋œ Domain Name)์„ ์„ค์ •ํ•˜๊ณ , ์ด๋ฅผ /etc/hosts File์— ๊ตฌ์„ฑ ๋ฐ ์ž…๋ ฅํ•˜์—ฌ OpenLDAP Domain Name์„ ์ •์˜ํ•ด ์ฃผ์–ด์•ผ ํ•ด์š”.

์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด Client Server์—์„œ FQDN์„ was.giggalpeople.com์œผ๋กœ ์„ค์ •ํ•ด ์ค„๊ฒŒ์š”.


hostnamectl set-hostname {์„ค์ •ํ•˜๊ณ ์ž ํ•˜๋Š” HostName}

 

vim /etc/hosts




์œ„์™€ ๊ฐ™์ด hosts File์— LDAP๊ณผ Client์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•ด ์ฃผ์—ˆ์–ด์š”.

์ฐธ๊ณ ๋กœ ์ฃผ๋‹ˆํ•˜๋ž‘์€ OpenLDAP Service๋ฅผ Docker๋กœ ๊ตฌ๋™ ์ค‘์ด๊ณ ,
ํ•ด๋‹น Docker๋Š” Host Server์™€ Port Mapping์ด ๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์œ„์™€ ๊ฐ™์ด OpenLDAP Port์™€ Mapping ๋œ
Host Port ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ์„ ํ•ด ์ฃผ์—ˆ์–ด์š”.


ํ•˜.์ง€.๋งŒ.
hosts File์—์„œ Port ๋ฒˆํ˜ธ๋ฅผ ์œ„์™€ ๊ฐ™์ด ์ž…๋ ฅํ•ด์ฃผ๋Š” ๊ฑด ์ธ์‹์ด ๋˜์ง€ ์•Š์•„์š”.

๊ทธ๋ž˜์„œ OpenLDAP์ด ์„ค์น˜๋œ Ubuntu 22.04 LTS Docker์— NGINX๋ฅผ ์ถ”๊ฐ€๋กœ ์„ค์น˜ํ•˜๊ณ , Reverse Proxy๋ฅผ ์ด์šฉํ•˜์—ฌ ํ†ต์‹ ์ด ๋˜๋„๋ก ๊ตฌ์„ฑํ•ด ๋ณด๋ ค๊ณ  ํ•ด์š”.

์ด์— ๋Œ€ํ•œ ๋‚ด์šฉ์€ ์ด ๊ณณ์— ์ค€๋น„ํ•ด ๋‘์—ˆ๋‹ต๋‹ˆ๋‹ค!


NGINX ์„ค์น˜ ๋ฐ ์ž‘์—…์„ ํ•˜์˜€๋‹ค๋ฉด ์ƒˆ๋กญ๊ฒŒ ์ƒ๊ธด NGINX Port๊ฐ€ ์ƒ๊ฒผ์„๊ฑฐ๊ณ ,
์ด๋ฅผ Docker Container์™€ Host Server์™€ Port Mapping์„ ํ•ด ์ฃผ์–ด์•ผ ํ•ด์š”.

์ด ์ž‘์—…์„ ์ง„ํ–‰ํ•ด๋ณผ๊ฒŒ์š”.

docker stop {Container ID}


์ตœ์ดˆ OpenLDAP Container๋ฅผ ์ค‘์ง€ ์‹œ์ผœ ์ฃผ์—ˆ์–ด์š”.


docker commit {Container Name} {๋งŒ๋“ค๊ณ ์ž ํ•˜๋Š” Image Name}



๊ทธ๋ฆฌ๊ณ  ์œ„์™€ ๊ฐ™์ด Docker Image๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ์–ด์š”!

๋ณ€๊ฒฝ ์ „


๊ธฐ์กด์— ํ•ด๋‹น Docker๋ฅผ ๊ธฐ๋™ํ•˜๊ธฐ ์œ„ํ•œ ๋ช…๋ น์–ด Shell Script์—์š”.
์—ฌ๊ธฐ๋‹ค๊ฐ€ NGINX Port Mapping์„ ์ถ”๊ฐ€ํ•ด ์ค„๊ฑฐ์—์š”.


๋ณ€๊ฒฝ ๋’ค


2๋ฒˆ์งธ์™€ 3๋ฒˆ์งธ, 4๋ฒˆ์งธ ์ค„๊ณผ ๊ฐ™์ด Port Mapping ์ •๋ณด๋ฅผ ์ถ”๊ฐ€ํ•ด ์ฃผ์—ˆ์–ด์š”.


docker rm {Container ID}


๊ทธ๋Ÿฐ ๋’ค ๊ธฐ์กด์— ์ค‘์ง€ํ•˜์˜€๋˜ Container๋ฅผ ์‚ญ์ œํ•ด ์ฃผ์—ˆ์–ด์š”.



๋‹ค์‹œ ํ•ด๋‹น Docker๋ฅผ ๊ธฐ๋™ํ•  ์ˆ˜ ์žˆ๋Š” Shell Script๋ฅผ ๋™์ž‘์‹œ์ผœ Container๋ฅผ ๊ธฐ๋™์‹œ์ผœ ์ฃผ์—ˆ์–ด์š”.


docker ps -a


ํ•ด๋‹น Container๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์˜ฌ๋ผ์™”๊ณ , ์ถ”๊ฐ€ํ–ˆ๋˜ NGINX Port Mapping๋„ ์ž˜ ๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.


service slapd start


ํ•ด๋‹น Container ์ฆ‰, OpenLDAP์„ ์„ค์น˜ํ•œ Ubuntu 22.04 LTS Container์— ์ ‘์†ํ•ด์„œ
๊ด€๋ จ Service๋ฅผ ๋ชจ๋‘ ๊ธฐ๋™ํ•ด ์ฃผ์—ˆ์–ด์š”.



๋‹ค์‹œ Client Server์—์„œ ์ž‘์—…์„ ์ด์–ด๊ฐ€ ๋ณด๋„๋ก ํ• ๊ฒŒ์š”.

vim /etc/hosts


hosts File์„ ์œ„์™€ ๊ฐ™์ด ๋‹ค์‹œ ๋ณ€๊ฒฝํ•ด ์ฃผ์—ˆ์–ด์š”.

ping -c3 {Domain ์ฃผ์†Œ}


์œ„์™€ ๊ฐ™์ด OpenLDAP Server Domain Name์œผ๋กœ Ping TEST๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ด๋ค„์ง€๋Š” ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์–ด์š”.





 

 

        ๐Ÿ“ฆ openldap-clients ๋ฐ nss-pam-ldapd ์„ค์น˜

์ด์ œ Client์— /etc/hosts File์„ ์„ค์ •ํ•œ ๋’ค openldap-clients์™€ nss-pam-ldapd์„ ์„ค์น˜ํ•  ๊ฒƒ์ด์—์š”.
์ด๊ฒƒ์„ ์„ค์น˜ํ•˜๊ฒŒ ๋˜๋ฉด OpenLDAP Server ์ ‘์†์—์„œ openldap-clients Package๋ฅผ ์ด์šฉํ•  ์ˆ˜ ์žˆ๊ณ , OpenLDAP ์‚ฌ์šฉ์ž ์ธ์ฆ์€ nss-pam-ldapd์„ ์ด์šฉํ•ด์„œ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์–ด์š”.

yum install -y openldap-clients nss-pam-ldapd

728x90


์œ„์™€ ๊ฐ™์ด ํ•„์š” Package๋ฅผ ๋‚ด๋ ค๋ฐ›๊ณ  ์„ค์น˜ํ•ด ์ฃผ์—ˆ์–ด์š”.



authconfig --enableldap --enableldapauth --ldapserver=ldap://ldap.giggalpeople.com --ldapbasedn=dc=giggalpeople,dc=com --enablemkhomedir --update

 



chmod 600 /etc/nslcd.conf


๊ทธ๋Ÿฐ ๋’ค ์œ„ ์„ค์ • File์€ ์ธ์ฆ ์ •๋ณด๊ฐ€ ๋“ค์–ด๊ฐ€ ์žˆ๊ฒŒ ๋˜๋Š”๋ฐ, ์ด์— ๋Œ€ํ•œ ๊ถŒํ•œ์„ ์„ค์ •ํ•ด ์ฃผ์—ˆ์–ด์š”.

๋งŒ์•ฝ RHEL 6๊ณ„์—ด์ด๋ผ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ํ•ด์ฃผ์–ด์•ผ ํ•ด์š”.

chmod 600 /etc/nslcd.conf /etc/pam_ldap.conf
๋ฐ˜์‘ํ˜•




cat /etc/openldap/ldap.conf


์„ค์ • ๋‚ด์šฉ์„ ํ™•์ธํ•ด ๋ณด๋ ค๊ณ  ํ•ด์š”.

์ฃผ๋‹ˆํ•˜๋ž‘์€ ์•„์ง TLS ์„ค์ •์„ ํ•˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์— URI์™€ BASE๋งŒ ํ™•์ธํ•ด ์ฃผ์—ˆ์–ด์š”.

vim /etc/nslcd.conf


์ฃผ๋‹ˆํ•˜๋ž‘์€ ์œ„์™€ ๊ฐ™์ด ์„ค์ •์„ ํ•ด ์ฃผ์—ˆ์–ด์š”.

service nslcd restart


๊ทธ๋Ÿฐ ๋’ค nslcd Service๋ฅผ ์žฌ๊ธฐ๋™ ํ•ด ์ฃผ์—ˆ์–ด์š”.

systemctl enable nslcd


Server๊ฐ€ ์žฌ๊ธฐ๋™ ๋˜๋”๋ผ๋„ ์ž๋™์œผ๋กœ Service๊ฐ€ ๋™์ž‘ํ•˜๊ฒŒ ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ์œ„์™€ ๊ฐ™์ด ํ•ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

๋งŒ์•ฝ RHEL 6 ๊ณ„์—ด์ด๋ผ๋ฉด ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด ์ฃผ๋ฉด ๋˜์š”.

chkconfig nslcd on

 

pwck -s && grpck -s


์œ„ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด /etc/passwd์™€ /etc/group, /etc/shadow File์„ ์ •๋ฆฌํ•ด ์ค„์ˆ˜ ์žˆ์–ด์š”.
์ •๋ฆฌ์˜ ๊ธฐ์ค€์€ uid์™€ gid ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌํ•ด์ค๋‹ˆ๋‹ค.



getent passwd {User ID}


์œ„์™€ ๊ฐ™์ด OpenLDAP์—์„œ ์ƒ์„ฑํ•œ ๊ณ„์ •์ด Client์—๋„ ๋งŒ๋“ค์–ด์ง„๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์–ด์š”.









๐Ÿง ์ฐธ๊ณ  ์ž๋ฃŒ

 

 

 

[RHCSA] Openldap Server + Client ( ์ž‘์„ฑ ์ค‘ )

Openldap Server : 192.168.0.5 /etc/hosts : testldap.co.kr Openldap Client : 192.168.0.3 /etc/hosts : test1 Openldap User : Client ๋Š” Server ์—์„œ ์ƒ์„ฑ๋œ ldapuser1 ๋ž€ ๊ณ„์ •์— ์ ‘์†ํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•จ. ์ ‘์†์‹œ autofs ๋กœ /home/guest/๊ณ„์ •๋ช…

myungin.tistory.com

 

 

 

LDAP System Administration Paperback

COUPANG

www.coupang.com

"์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค."

 

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•