PAM(Pluggable Authentication Module)
1. PAM(Pluggable Authentication Module)
»ç¿ëÀÚ¸¦ ÀÎÁõÇÏ°í ±× »ç¿ëÀÚÀÇ ¼ºñ½º¿¡ ´ëÇÑ ¾×¼¼½º¸¦ Á¦¾îÇÏ´Â ¸ðµâÈµÈ ¹æ¹ý
PAMÀº °ü¸®ÀÚ°¡ ÀÀ¿ëÇÁ·Î±×·¥µéÀÇ »ç¿ëÀÚÀÎÁõ¹æ¹ýÀ» ¼±ÅÃÇÒ ¼ö ÀÖµµ·Ï ÇØÁØ´Ù.
2. PAMÀÇ µ¿ÀÛ
PAM¶óÀ̺귯¸®´Â /etc/pam.d¿¡¼ °¢ ½Ã½ºÅÛ¿¡ ¸Â°Ô ¼³Á¤ÇÏ¿©, °¢ ½Ã½ºÅÛ¿¡¼ »ç¿ë°¡´ÉÇÑ ÀÎÁõ ¸ðµâÀ» ÅëÇØ »ç¿ëÀÚÀÇ ÀÎÁõ ¿ä±¸¸¦ ó¸®
3. PAMÀÇ ±¸¼ºÆÄÀÏ
- /etc/pam.d µð·ºÅ丮¿¡ ¼³Ä¡
- PAMÆÄÀÏÀÇ ±¸¼º¹®¹ý
±¸Á¶ : type control module-path module-arguments
ex) # cat login
auth include system-auth
account required pam_nologin.so
password include system-auth
session required pam_selinux.so close
session include system-auth
- type : ¾î¶² ŸÀÔÀÇ ÀÎÁõÀÌ »ç¿ëµÉ °ÍÀÎÁö¸¦ ¾Ë·ÁÁÜ
°°Àº ŸÀÔÀÇ ¸ðµâÀº ½×ÀÏ ¼ö ÀÖ°í, »ç¿ëÀÚ¿¡ ÀÎÁõµÇ±â À§ÇÑ ´ÙÁß ¿ä±¸»çÇ×À» ¸¸Á·Çϵµ·Ï ¿äûÇÒ ¼ö ÀÖ´Ù.
• account: »ç¿ëÀÚ°¡ ÇØ´ç ¼ºñ½º¿¡ Á¢±ÙÀÌ Çã¿ëµÇ¾ú´ÂÁö, Æнº¿öµå°¡ ±â°£ÀÌ ¸¸·á°¡ µÇ¾ú´ÂÁö¸¦ °áÁ¤.
• auth: Æнº¿öµå º¸´Ù Á¤±³ÇÑ ¹æ¹ýÀ» ÅëÇؼ »ç¿ëÀÚ°¡ ÀÎÁõ °áÁ¤
• password: »ç¿ëÀÚ°¡ ÀÎÁõ¹æ¹ýÀ» º¯°æÇϵµ·Ï Á¦°ø
• session: »ç¿ëÀÚ°¡ ÀÎÁõ¹Þ±â ÀüÈÄ¿¡ ÇØ¾ß ÇÒ °ÍÀ» ³ªÅ¸³½´Ù.
- control : ÅëÁ¦¸¦ ´ã´çÇÏ´Â ºÎºÐ, PAM¿¡ ¹«¾ùÀ» ÇؾßÇÒ Áö¸¦ ¾Ë·ÁÁØ´Ù.
• requisite: ¸ðµâÀ» ÀÌ¿ëÇÏ´Â ÀÎÁõÀÌ ½ÇÆÐÇÒ °æ¿ì, Áï½Ã ÀÎÁõÀ» °ÅºÎ
• required: ÀÎÁõÀÌ °ÅºÎµÇ±â Àü¿¡ ºñ·Ï PAMÀÌ ÀÌ ¼ºñ½º¿¡ µî·ÏµÈ ´Ù¸¥ ¸ðµç ¸ðµâµéÀ» ¿ä±¸ÇÔ¿¡µµ ºÒ±¸ÇÏ°í ½ÇÆÐÇÒ °æ¿ì ÀÎÁõÀ» °ÅºÎ
• sufficient: ºñ·Ï ÀÌÀü¿¡ ¿äûµÇ¾îÁø ¸ðµâÀÌ ½ÇÆÐÇÏ´õ¶óµµ ÀÌ ¸ðµâ¿¡ ÀÇÇؼ ÀÎÁõÀÌ ¼º°øÇÒ °æ¿ì, PAMÀº ÀÎÁõÀ» ½ÂÀÎÇÑ´Ù.
• optional : ¼ºñ½º¿¡ ´ëÇÑ ÀÀ¿ëÇÁ·Î±×·¥ÀÇ ¼º°ø/½ÇÆп¡ Áß¿äÇÏÁö ¾Ê´Ù´Â °ÍÀ» ÀǹÌ
- module-path : ¸ðµâ°æ·Î, ex)/lib/security
- module-argument : ¸ðµâ¿¡°Ô Àü´ÞµÇ´Â Àμö
4. /etc/pam.d : ƯÁ¤ÇÑ ¼ºñ½º¿¡ ´ëÇÑ ¿äûÀÌ ¿À¸é /etc/pam.d µð·ºÅ丮¾ÈÀÇ ÆÄÀÏÀÇ ¼³Á¤À» º¸°í ó¸®Çϸç,
±× ¿ÜÀÇ ¼ºñ½ºµéÀº /etc/pam.d/other¿¡¼ ó¸®ÇÑ´Ù.
- login : ½´ÆÛÀ¯Àú·Î ·Î±×ÀÎÇÒ ¼ö ÀÖ´Â »ç¿ëÀÚ ÀÎÁõ°ú °ü·ÃµÈ ÆÄÀÏ
ex)# cat /etc/pam.d/login
auth required /lib/security/pam_securetty.so
// pam_securetty.so ¸ðµâÀÌ ÁöÁ¤ÇسõÀº º¸¾È ±ÔÄ¢À» ¸¸Á·Çؾ߸¸ ·Î±×ÀÎÀÌ Çã¿ë
// ÀÌ ¸ðµâ /etc/securetty ÆÄÀÏ¿¡¼ ÁöÁ¤µÇ¾îÀÖ´Â tty¿¡¼ ¿äûÇÑ ½´ÆÛÀ¯Àú¸¸ ·Î±×ÀÎÀ» Çã¿ëÇÑ´Ù.
- other : PAM¿¡¼ º°µµ·Î ÁöÁ¤ÇÏÁö ¾ÊÀº ¼ºñ½º¿¡ ´ëÇÑ ÀÎÁõÀ» À§ÇÑ ÂüÁ¶ÇÏ´Â ÆÄÀÏ
ex)# cat other
auth required /lib/security/pam_deny.so
account required /lib/security/pam_deny.so
password required /lib/security/pam_deny.so
session required /lib/security/pam_deny.so
//¾ËÁö ¸øÇÏ´Â ¼ºñ½º°¡ 4°³ÀÇ ±¸¼ºÅ¸ÀÔ Áß ¾î¶² °÷¿¡ Á¢±ÙÀ» ½ÃµµÇÏ´õ¶óµµ PAMÀº ÀÎÁõÀ» °ÅºÎÇÑ´Ù.(pam_deny.so ¸ðµâ)
5. ¸ðµâ ¼³¸í
- pam_securetty.so
: Ç¥ÁØÀÇ UNIX securetty°Ë»çÇؼ /etc/securettyÆÄÀÏ¿¡ ±â·ÏµÈ ³»¿ë°ú ºñ±³Çϴµ¥ root°èÁ¤ÀÎ °æ¿ì¿¡¸¸ È®ÀÎ
±× ¿ÜÀÇ ´Ù¸¥ »ç¿ëÀÚ¿¡ ´ëÇؼ´Â Ç×»ó ÀÎÁõÀÌ ¼º°øÇÑ °ÍÀ¸·Î ó¸®
»ç¿ëµÈ °÷ : /etc/pam.d/login µî
- pam_listfile.so
: ÀÓÀÇÀÇ ÆÄÀÏ¿¡ ´ëÇØ ¼ºñ½º¸¦ Çã°¡Çϰųª °ÅºÎÇÏ´Â ¹æ¹ýÀ» Á¦°ø
module-argument • onerr=succeed|fail : onerr=succeedÀ̸é PAM_SUCCESS¸¦ ¸®ÅÏÇÏ°í,
onerr=failÀ̸é PAM_AUTH_ERR ¶Ç´Â PAM_SERVICE_ERRÀÌ ¸®ÅÏ
• file=filename : ÁöÁ¤ÇÑ ÆÄÀÏÀ» Àд´Ù. ÇÑÁÙ¿¡ ÇÑ ¾ÆÀÌÅÛ¸¸ Àû´Â´Ù.
• ense=allow|deny : allow´Â ƯÁ¤ÇÑ ¾ÆÀÌÅÛÀÌ ¹ß°ßµÇ¸é PAM_SUCCESS°¡ ¸®ÅÏµÇ°í ±ÇÇѿ䱸´Â ¼º°ø
°ªÀÌ denyÀ̸é PAM_AUTH_ERRÀÌ ¸®ÅÏµÇ°í ±ÇÇѿ䱸´Â ½ÇÆÐÇÑ´Ù.
• item=user|tty|rhost|ruser|group|shell => ¾ÆÀÌÅÛÀ» ÁöÁ¤ÇÑ´Ù. °¢°¢ »ç¿ëÀÚ¸í, ¿äûÇÑ Å͹̳Î, ¿ø°Ý»ç¿ëÀÚ,±×·ì,½©À» ³ªÅ¸³½´Ù.
• apply=user|@group => ƯÁ¤»ç¿ëÀÚ ¶Ç´Â ÁÖ¾îÁø ±×·ìÀ¸·Î Àû¿ëÀ» Á¦ÇÑÇϴµ¥ »ç¿ëÇÑ´Ù.
- pam_nologin.so
: /etc/nologinÆÄÀÏÀÌ Á¸ÀçÇϸé root¸¸ ·Î±×ÀÎÇÒ ¼ö ÀÖ°í ´Ù¸¥ »ç¿ëÀÚ´Â ¿¡·¯¸Þ½ÃÁö¿Í ÇÔ²² °ÅºÎ
/etc/nologinÆÄÀÏÀÌ ¾ø´Ù¸é ¸ðµâÀº ¼º°øÀ» ¸®ÅÏ
»ç¿ëµÈ°÷: /etc/pam.d/login
- pam_deny.so
: ÀÌ ¸ðµâÀº Á¢±ÙÀ» °ÅºÎÇÏ´Â µ¥ »ç¿ë
- pam_cracklib.so
: ÀÌ ¸ðµâÀº password¸¦ ¼³Á¤ÇÑ Á¤Ã¥°ú ºñ±³,°Ë»çÇÑ´Ù.
¸ðµâÀÎÀÚ • debug : ¸ðµâÀÌ µ¿ÀÛÀ» º¸¿©ÁÖ±â À§ÇØ syslog¿¡ Á¤º¸¸¦ ³²±â´Âµ¥ ÀÌ ¿É¼ÇÀ» »ç¿ëÇϸé Æнº¿öµåÁ¤º¸¸¦ ³²±âÁö ¾Ê´Â´Ù.
• type=LINUX : ¸ðµâÀÇ ±âº» µ¿ÀÛÀº Æнº¿öµå¸¦ ¹°¾îº¼ ¶§ "New UNIX password: "¶ó°í ¹¯´Âµ¥,
ÀÌ ¿É¼ÇÀ» »ç¿ëÇÏ¿© 'UNIX'¶ó´Â ¸» ´ë½Å 'LINUX'·Î ¹Ù²Ü ¼ö ÀÖ´Ù.
• retry=N : »õ Æнº¿öµå¸¦ ¹°¾îº¸´Â Ƚ¼ö·Î¼ ±âº»°ªÀº 1ÀÌ´Ù. ÀÌ ¿É¼ÇÀ» »ç¿ëÇϸé N¸¸Å Ƚ¼ö¸¦ ´Ã¸± ¼ö ÀÖ´Ù.
• difok=N : »õ Æнº¿öµå¿¡¼ ¿¹Àü Æнº¿öµå¿¡ ÀÖÁö ¾Ê´Â ¹®ÀÚµéÀ» ¸îÀÚ³ª »ç¿ëÇØ¾ß ÇÏ´ÂÁö ³ªÅ¸³»´Â ¼ö·Î ±âº»°ªÀº 10ÀÌ°í, »õ Æнº¿öµå¿¡¼ 1/2ÀÌ»óÀÇ ±ÛÀÚ°¡ ÀÌÀü°ú ´Ù¸£´Ù¸é »õ Æнº¿öµå·Î ¹Þ¾Æµé¿© Áø´Ù.
• minlen=N : »õ Æнº¿öµåÀÇ ÃÖ¼Ò Å©±â¿¡ 1À» ´õÇÑ Å©±âÀÌ´Ù.
»õ Æнº¿öµå¿£ »ç¿ëµÈ ¹®ÀÚ¿ÀÇ ±æÀÌ¿Ü¿¡ °¢ ¹®ÀÚÁ¾·ù(¼ýÀÚ, ´ë¹®ÀÚ, ¼Ò¹®ÀÚ, Ư¼ö¹®ÀÚ)¸¦ »ç¿ëÇÑ °Í¿¡ ´ëÇØ °¢°¢ Å©·¹µðÆ®(credit)¸¦ ÁØ´Ù.
• dcredit=N : ¼ýÀÚ¹®ÀÚ°¡ °¡Áú ¼ö ÀÖ´Â Å©·¹µðÆ®°ªÀ» ÁöÁ¤ÇÑ´Ù. ±âº»°ªÀº 1ÀÌ´Ù.
• ucredit=N : ´ë¹®ÀÚ°¡ °¡Áú ¼ö ÀÖ´Â Å©·¹µðÆ®°ªÀ» ÁöÁ¤ÇÑ´Ù. ±âº»°ªÀº 1ÀÌ´Ù.
• lcredit=N : ¼Ò¹®ÀÚ°¡ °¡Áú ¼ö ÀÖ´Â Å©·¹µðÆ®°ªÀ» ÁöÁ¤ÇÑ´Ù. ±âº»°ªÀº 1ÀÌ´Ù.
• ocredit=N : Ư¼ö¹®ÀÚ°¡ °¡Áú¼ö ÀÖ´Â Å©·¹µðÆ®°ªÀ» ÁöÁ¤ÇÑ´Ù. ±âº»°ªÀº 1ÀÌ´Ù.
• use_authok : ÀÌ ÀÎÀÚ´Â »ç¿ëÀÚ¿¡°Ô »õ Æнº¿öµå¸¦ ¹¯Áö¸»°í ¾Õ¼ ½ÇÇàµÈ Æнº¿öµå¸ðµâ¿¡¼ ¹ÞÀº °ÍÀ» »ç¿ëÇϵµ·Ï ¸ðµâ¿¡°Ô °Á¦ÇÑ´Ù.
- pam_wheel.so
: root±ÇÇÑÀ» ¾òÀ» ¼ö ÀÖ´Â »ç¿ëÀÚ¸¦ wheel(gid=0)À̶ó´Â ±×·ìÀ¸·Î ¹¾î¼ »ç¿ëÇϵµ·Ï Áö¿øÇÏ´Â ¸ðµâÀÌ´Ù.
¸ðµâÀÎÀÚ • debug : syslog¿¡ ´õ ¸¹Àº Á¤º¸¸¦ Á¦°øÇÑ´Ù.
• group=±×·ì¸í : gid=0ÀÎ ±×·ìÀ» °Ë»çÇÏ´Â ´ë½Å ÀÎÁõÀ» À§Çؼ '±×·ì¸í'±×·ìÀ» °Ë»çÇÑ´Ù. ¿©±â¼ ±×·ì¸íÀº ±×·ìÀÇ À̸§ÀÌÁö ¼ýÀÚ·Î µÈ ±×·ìÀÇ id°¡ ¿Í¼´Â ¾ÈµÈ´Ù.
• trust : ÀÌ ¿É¼ÇÀ» »ç¿ëÇϸé root±ÇÇÑÀ» ¿ä±¸ÇÑ »ç¿ëÀÚ°¡ wheel±×·ì¿¡ ¼ÓÇÑ °æ¿ì PAM_SUCCESS¸¦ µ¹·ÁÁÖµµ·Ï ÇÑ´Ù.
• deny : ¸ðµâÀÇ µ¿ÀÛÀ» ¹Ý´ë·Î Çϵµ·Ï ¸¸µç´Ù.
• use_uid : loginÇÒ ¶§ÀÇ À̸§À» ÀÌ¿ëÇÏÁö ¾Ê°í uid¸¦ ÀÌ¿ëÇÑ´Ù.
»ç¿ëµÈ °÷: /etc/pam.d/su
6. PAMÀÇ »ç¿ë¿¹
- »ç¿ëÀÚ Æнº¿öµå ±æÀÌ Á¦ÇÑÇϱâ
: ¸®´ª½º¿¡¼ Æнº¿öµå ±âº»¼³Á¤°ú °ü·ÃµÈ ÆÄÀÏÀÌ /etc/login.defsÀÌ´Ù.
ÀÌ ÆÄÀÏ¿¡¼ Æнº¿öµåÀÇ ±æÀÌ´Â ÃÖ¼Ò 5ÀÚ·Î ¼³Á¤ÇÏ°í ÀÖ´Ù. ÀÌ ÆÄÀÏ¿¡¼ ¼³Á¤Çصµ µÇÁö¸¸ PAMÀ» ÀÌ¿ëÇÏ¿© Æнº¿öµåÀÇ ±æÀ̸¦ ¼³Á¤ÇÒ ¼ö ÀÖ´Ù.
±âº» ¼³Á¤ÆÄÀÏÀº /etc/pam.d/passwdÀÌ´Ù.
# cat /etc/pam.d/passwd
#%PAM-1.0
auth required /lib/security/pam_stack.so service=system-auth
account required /lib/security/pam_stack.so service=system-auth
password required /lib/security/pam_stack.so service=system-auth
// ÇöÀç Æнº¿öµå°ü·Ã Á¤Ã¥Àº /etc/pam.d/system-authÀÇ ¼³Á¤À» µû¸¥´Ù´Â ¶æ
# cat /etc/pam.d/system-auth
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth required /lib/security/pam_env.so
auth sufficient /lib/security/pam_unix.so likeauth nullok
auth required /lib/security/pam_deny.so
account required /lib/security/pam_unix.so
password required /lib/security/pam_cracklib.so retry=3 type=
password sufficient /lib/security/pam_unix.so nullok use_authtok md5 shadow
password required /lib/security/pam_deny.so
session required /lib/security/pam_limits.so
session required /lib/security/pam_unix.so
- Æнº¿öµå ±æÀÌÁ¦ÇÑÀ» À§ÇÑ /etc/pam.d/passwd ÆÄÀÏ ¼öÁ¤ (3¹ø°ÁÙÀ» »èÁ¦ÇÏ°í ¾Æ·¡¿Í °°ÀÌ 3ÁÙÀ» Ãß°¡)
# cat /etc/pam.d/passwd
#%PAM-1.0
auth required /lib/security/pam_stack.so service=system-auth
account required /lib/security/pam_stack.so service=system-auth
#password required /lib/security/pam_stack.so service=system-auth
password required /lib/security/pam_cracklib.so retry=3 minlen=12 type=LINUX
password sufficient /lib/security/pam_unix.so nullok use_authok md5 shadow
password required /lib/security/pam_deny.so
//±âÁ¸ÀÇ ³»¿ëÀ» ÁÖ¼®Ã³¸®ÇÏ¿´´Ù. »õ·ÎÀÌ ¼³Á¤ÇÑ ³»¿ëÀº Æнº¿öµå¸¦ /etc/pam.d/system-authÆÄÀÏÀÇ ¼³Á¤À» µû¸£Áö ¾Ê°í »õ·Î¿î ¸ðµâ·Î ¼³Á¤ÇÏ¿´´Ù.
# cat /etc/pam.d/system-auth
#%PAM-1.0 # This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth required /lib/security/pam_env.so
auth sufficient /lib/security/pam_unix.so likeauth nullok
auth required /lib/security/pam_deny.so
account required /lib/security/pam_unix.so
session required /lib/security/pam_limits.so
session required /lib/security/pam_unix.so
// Æнº¿öµå °ü·ÃµÈ ºÎºÐÀ» /etc/pam.d/passwd¿¡¼ Á÷Á¢ °ü¿©ÇϹǷΠÀÌ ÆÄÀÏ¿¡¼ password°ü·Ã 3°³ÀÇ Ç׸ñÀ» Á¦°Å
- Å×½ºÆ®
# passwd
Changing password for user posein.
Changing password for posein
(current) UNIX password:
New LINUX password: // LINUX¶ó´Â ¹®±¸¿ÀÌ º¸ÀδÙ.
Retype new LINUX password: // LINUX¶ó´Â ¹®±¸¿ÀÌ º¸ÀδÙ.
Enter new UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully
//retry=3 À¸·Î ¼³Á¤Çؼ 3¹ø ¹°¾îº»´Ù