³ë¹«Çö ´ëÅë·É ¹è³Ê
  ±è¼ºÅÂÀÇ Tech Tips(Linux, PHP, Apache, DBMS, Mobile)
  http://www.supersky.pe.kr  
¾È³çÇϽʴϱî? ±è¼ºÅÂÀÔ´Ï´Ù.
Linux, Apache, PHP, Mysql, Mobile °ü·Ã Tech Tips Á¤º¸¸¦ Á¦°øÇÕ´Ï´Ù.
 
<<   2024 Dec   >>
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
2930311234
1877341 385
  
DNS Powered by DNSEver.com
  ++ [Æß] »ç¿ëÀÚ µî·Ï À¯Æ¿ ½ºÅ©¸³Æ®  -  2005/06/26 19:20
1. Linux ÀÇ °æ¿ì

./adduser_sh USERNAME PASSWORD HOME_DIR

-------------- adduser_sh cut here ------------------
#!/bin/sh

CHK=
user=${1}
pass=${2}
home=${3}

[ -n "${home}" ] && home="-d ${home}"

adduser ${user} ${home}
CHK=$?

if [ $CHK -ne 0 ]; then
exit 1
fi

echo "${pass}" | passwd ${user} --stdin
CHK=$?

if [ $CHK -ne 0 ]; then
exit 1
fi

exit 0
-------------- adduser_sh cut here ------------------




2. Other OS ÀÇ °æ¿ì

Linux °¡ ¾Æ´Ò °æ¿ì¿¡´Â passwd ¿¡¼­ --stdin ÀÌ Áö¿øÀÌ µÇÁö ¾ÊÀ¸
¹Ç·Î adduser ÀÇ -p ¿É¼ÇÀ» »ç¿ëÇØ¾ß ÇÑ´Ù. ¹°·Ð adduser ¿¡¼­ -p ¿É¼Ç
ÀÌ Áö¿øµÇÁö ¾Ê´Â´Ù¸é »ç¿ëÇÒ ¼ö ¾ø´Ù.

¶ÇÇÑ, ÀÌ ¹æ¹ýÀ» »ç¿ëÇÒ °æ¿ì¿¡´Â password ¸¦ encoding ÇÑ °ªÀ» »ç¿ë
ÇØ¾ß ÇϹǷΠº°µµ ÀÇ utility °¡ ÇÊ¿äÇÏ´Ù.




2.1 apache °¡ ¼³Ä¡µÇ¾î ÀÖÀ» °æ¿ì

-------------- adduser_sh cut here ------------------
#!/bin/sh

# md5 ¾Ïȣȭ°¡ Áö¿øÀÌ µÉ °æ¿ì.
# ¾ÈµÉ °æ¿ì¿¡´Â 0À¸·Î ¼³Á¤ÇÒ °Í.
# passwd ³ª shadow ÆÄÀÏ¿¡¼­ ¾ÏȣȭµÈ Æнº¿öµåÀÇ ±æÀÌ°¡
# 8°¡ À̸é 0À¸·Î ¼³Á¤ÇØ¾ß ÇÔ.
md5opt=1

CHK=
user=${1}
pass=${2}
home=${3}

[ -n "${home}" ] && home="-d ${home}"

if [ -n "${pass} ]; then
[ $md5opt -eq 1 ] && mdopt="-m"
pass=$(htpasswd $mdopt -n b {$user} | sed 's/.*://g')
pass="-p \"${pass}\""
fi

adduser ${user} ${home} {$pass}
CHK=$?

if [ $CHK -ne 0 ]; then
exit 1
fi

exit 0
-------------- adduser_sh cut here ------------------



2.1 apache °¡ ¼³Ä¡µÇ¾î ÀÖÁö ¾ÊÀ» °æ¿ì

ÀÌ °æ¿ì´Â ¾Ïȣȭ À¯Æ¿¸®Æ¼°¡ ÀÖ¾î¾ß ÇÑ´Ù. ÀÌ À¯Æ¿¸®Æ¼´Â
http://linux-sarang.net/board/?p=read&table=tip&no=10549
¿¡¼­ ÆÛ¿Ô´Ù.

-------------genpass.c-------------------------------
#include

int
main(int argc, char *argv[])
{
   char *cypher;
   char *salt = argv[1];
   char *key = argv[2];

   cypher = crypt(key, salt);
   printf("%s\n", cypher);
   return 0;
}
-------------genpass.c-------------------------------

genpass.c ¶ó´Â ÆÄÀÏÀ» ¸¸µé¾î À§ÀÇ ³»¿ëÀ» ±âÀÔÇÑ´Ù. ´ÙÀ½

gcc -O2 -o genpass genpass.c
install -m 700 genpass /usr/local/sbin/genpass

°ú °°ÀÌ ¸í·ÉÀ» ½ÇÇàÇÑ´Ù.

±×¸®°í ¾Æ·¡¿Í °°ÀÌ ½ºÅ©¸³Æ®¸¦ ¸¸µé¾î »ç¿ëÇÏ¸é µÈ´Ù.

-------------- adduser_sh cut here ------------------
#!/bin/sh

CHK=
user=${1}
pass=${2}
home=${3}

[ -n "${home}" ] && home="-d ${home}"

if [ -n "${pass} ]; then
pass=$(/usr/local/sbin/genpass {$user} {$pass})
pass="-p \"${pass}\""
fi

adduser ${user} ${home} {$pass}
CHK=$?

if [ $CHK -ne 0 ]; then
exit 1
fi

exit 0
-------------- adduser_sh cut here ------------------






      << prev     1 ...  139  140  141  142  143  144  145  146  147 ...  162     next >>