°Ô½Ã¹° 1,369°Ç
   
¸í·É¾î Çϳª·Î ¿©·¯´ë ÀÚ¿ø °ü¸®Çϱâ (SSH ÀÎÁõÅ° »ç¿ë)
±Û¾´ÀÌ : ÃÖ°í°ü¸®ÀÚ ³¯Â¥ : 2010-01-26 (È­) 11:06 Á¶È¸ : 12017
±ÛÁÖ¼Ò :
                                

¹®Á¦ÀÇ ¿äÁ¡Àº ¿©·¯´ëÀÇ µ¿ÀÏÇÑ ½Ã½ºÅÛÀ» °ü¸®Çϴµ¥ À־ ¹Ýº¹µÇ´Â ÀÛ¾÷ÀÌ Àæ´Ù´Â°Í..
ÀÌ°É ¾î¶»°ÔÇϸé Á»´õ Æí¸®ÇÏ°Ô ÇÒ¼ö ÀÖ´À³Ä¿¡¼­ Ãâ¹ßÇÑ´Ù.

¹°·Ð ÁÖ±âÀûÀ¸·Î ¹Ýº¹µÇ´Â ¸í·É¾î ÀÛ¾÷À̶ó¸é CRONÀ» ÅëÇؼ­ ½ºÄÉÁÙÀ» °É¾îµÎ¸é µÇ°ÚÁö¸¸ ¹®Á¦´Â ºñÁ¤±âÀûÀÎ ÀÛ¾÷ÀÌ´Ù.

¿ø¸®´Â SSH ÀÎÁõÅ°¸¦ °¡Áö°í ½ºÅ©¸³Æ®¸¦ ¸¸µé¾î¼­ ÀÛ¾÷Çϸé 100´ë, 1000´ë¶óµµ ¹®Á¦ ¾ø´Ù´Â°Í!!
SSH ÀÎÁõÅ°¶õ °£´ÜÈ÷ ¸»Çؼ­ ³ª¿Í ¼­¹ö°£ÀÇ ¾à¼ÓµÈ Å°ÀÌ´Ù.


ÀÎÁõÅ° »ý¼ºÇϱâ
ÀÎÁõÅ°´Â ssh-keygen¸¦ ÅëÇؼ­ ¸¸µç´Ù. Å°¸¦ »ý¼ºÇÒ¶§ »ç¿ëÇÒ Å°ÀÇ ÇüŸ¦ ÁöÁ¤ÇØ Áִµ¥ ¿ø°Ý ¼­¹ö°¡ SSH ÇÁ·ÎÅäÄÝ ¹öÀü 2¸¦ Áö¿øÇÑ´Ù¸é(¿äÁòÀº ±âº»Áö¿øÇÑ´Ù.)  rsa, dsa  ÇÁ·ÎÅäÄÝ 1¸¸À» Áö¿øÇÑ´Ù¸é rsa1 À» »ç¿ëÇÏ¸é µÈ´Ù.
ÄÁÆ®·ÑÇÒ ¼­¹ö¿¡¼­ ÀÎÁõÅ°¸¦ »ý¼ºÇÑ´Ù.

Å°°¡ ÀúÀåµÉ °÷°ú À̸§À» ¹°¾î ¿À´Âµ¥ µðÆúÆ®·Î ±×³É ¿£Å͸¦ Ä¡°í ³Ñ¾î°¡¸é, ´ÙÀ½°ú °°ÀÌ ÀÎÁõÅ° ¾ÏÈ£¸¦ ¹°¾î¿Â´Ù. ¿øÇÏ´Â ¾ÏÈ£¸¦ µÎ¹ø ¹Ýº¹Çؼ­ ÀÔ·ÂÇØÁÖ¸é Å°°¡ »ý¼ºµÈ´Ù.
ÀÎÁõÅ° »ý¼º½Ã ÀÎÁõÅ° ¾ÏÈ£¸¦ °ø¹éÀ¸·Î (passphrase ¸¦ ¹°¾î¿Ã¶§ ±×³É ¿£Å͸¦ Ä¡¸é µÈ´Ù) ¸¸µé°æ¿ì¿¡´Â ssh Á¢¼Ó½Ã ¾ÏÈ£¸¦ ÀÔ·ÂÇÏÁö ¾Ê¾Æµµ ±×³É Á¢¼ÓÀÌ µÇ¹Ç·Î Æí¸®Çϳª Å°°ü¸®¿¡ ÁÖÀǸ¦ ±â¿ï¿©¾ß ÇÑ´Ù...

¿ì¸®´Â ¾ÏÈ£¾øÀÌ Á¢±ÙÇÏ·Á°í Çϴϱñ ±×³É ¿£ÅÍ (Enter)  

[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
ea:24:ca:36:af:99:e6:4f:96:d2:b6:0f:25:75:fc:ea mojily@chonnom.com

¡Ø -t : type   Specify type of key to create.


°ø°³Å° »ç¿ëÇϱâ
±âº» °æ·Î¿¡ Å°¸¦ ÀúÀåÇÏ¿´´Ù¸é /root/.ssh/ À§Ä¡¿¡ id_rsa ¿Í id_rsa.pub°¡ »ý¼ºµÇ¾î ÀÖ´Ù.
.pub È®ÀåÀÚ°¡ ºÙÀº °ÍÀÌ °ø°³Å°·Î ÀÌ ÆÄÀÏÀ» °ü¸®ÇÒ ¿ø°Ý¼­¹öµéÀÇ ~/.ssh/ ¿¡ authorized_keys ¶ó´Â À̸§À¸·Î º¹»çÇØÁØ´Ù.
scp ¸¦ ÀÌ¿ëÇؼ­ ÆÄÀÏÀ» ¹Ð¾î ³Ö¾îÁØ´Ù.

[root@localhost .ssh]# scp id_rsa.pub root@xxx.xxx.xxx.xxx:/root/.ssh/authorized_keys
root@xxx.xxx.xxx.xxx's password:
id_rsa.pub                                                                                                                  100%  397     0.4KB/s   00:00


°ü¸®´ë»óÀÇ ¼­¹öµé¿¡ Á¢¼ÓÇؼ­ º¸¸é authorized_keys ºÎºÐÀÌ È®ÀεȴÙ.

[root@localhost .ssh]# ls -al
total 24
drwxr-xr-x 2 root root 4096 Jan 26 11:29 .
drwxr-x--- 5 root root 4096 Jan 26 11:29 ..
-rw-r--r-- 1 root root  397 Jan 26 11:29 authorized_keys


±âº»ÀûÀÎ ÀÛ¾÷Àº ´Ù ³¡³µ´Ù...
ÄÁÆ®·ÑÇÒ ¼­¹ö¿¡¼­ ÀÛ¾÷´ë»ó ¿ø°Ý ¼­¹ö·Î ssh Á¢±ÙÀ» ½ÃµµÇغ¸¸é...¾ÏÈ£ÀÎÁõ¾øÀÌ ·Î±×ÀÎÀÌ µÇ´Â°É È®Àΰ¡´ÉÇÏ´Ù.

[root@mojily .ssh]# ssh -lroot xxx.xxx.xxx.xxx
Last login: Tue Jan 26 11:32:28 2010 from xxx.xxx.xxx.xxx
[root@localhost ~]#


ÀÌÁ¦´Â ÀÌ°É ½ºÅ©¸³Æ®È­ ½ÃÄѼ­ ¸®½ºÆ®·Î °ü¸®ÇÏ´Â ºÎºÐÀÌ´Ù.
³ª °°Àº °æ¿ì¿¡´Â IDC º°·Î ¼­¹ö°¡ Á¸ÀçÇÏ¿© ÇÔ¼ö¸¦ ÀÌ¿ëÇؼ­ °ü¸®´ë»ó ¼­¹öµéÀ» ³ª´­°ÍÀÌ´Ù.
 - remote_controal.sh

function get_nodes_1
{
cat <<EOF
192.168.0.111
192.168.0.112
EOF
}

function get_nodes_2
{
cat <<EOF
192.168.1.111
192.168.1.112
EOF
}

function get_nodes_3
{
cat <<EOF
192.168.2.111
192.168.2.112
EOF
}

case "$1" in

sh)

echo "###########################################"
echo "#                         [1] KT-ICC                               #"
echo "#                         [2] LG-Dacom                          #"
echo "#                         [3] SK-IDC                               #"
echo "###########################################"

echo -n "Select Center Number ^^;; : "
read num

get_nodes_$num | while read server ; do
        ssh -q -o 'BatchMode yes' $server "$2"  &
        wait
done;;

help)          # sh ¿É¼ÇÀ» ÅëÇؼ­ ¸í·É¾î Àü´Þ!!
cat <<EOF
sh
EOF
;;
*)

$0 sh "$1"
;;
esac

¡Ø usage: ssh [-1246AaCfgkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]
           [-D port] [-e escape_char] [-F configfile]
           [-i identity_file] [-L [bind_address:]port:host:hostport]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-R [bind_address:]port:host:hostport] [-S ctl_path]
           [user@]hostname [command]


°£´ÜÇÏ°Ô ¼³¸íÇÏÀÚ¸é get_nodes1 / get_nodes_2 / get_nodes_3 À̶ó´Â ¸®½ºÆ®·Î ¼­¹ö¸¦ ³ª´©°í Select Number ¿¡ ÀÇÇؼ­ ¼±ÅÃµÈ ±×·ìÀ¸·Î while ¹®À» ÀÌ¿ëÇØ ¸í·É¾î¸¦ º¸³½´Ù´Â °ÍÀÌ´Ù.


EX )»ç¿ë¹ý ¿¹Á¦
 - ¼­¹ö°¡ ¿©·Á´ëÀÏ °æ¿ì ¾î¶²¼­¹öÀÎÁö È®ÀÎÀÌ ¾ÈµÇ´Ï±ñ... hostname À¸·Î ¼­¹ö¸¦ Âï¾îÁÖ°í ÇØ´ç ¼­¹ö¿¡ ³¯Â¥¿Í ½Ã°£À» È®ÀÎÇÏ´Â ¿¹Á¦ÀÌ´Ù.

[root@localhost ]# ./remote_controal.sh 'hostname; date'

###########################################
#                         [1] KT-ICC                               #
#                         [2] LG-Dacom                          #
#                         [3] SK-IDC                               #
###########################################

Select Number ^^;; : 3
SK1
Tue Jan 26 11:24:27 KST 2010
SK2
Tue Jan 26 11:24:27 KST 2010 

À̸§ Æнº¿öµå
ºñ¹Ð±Û (üũÇÏ¸é ±Û¾´À̸¸ ³»¿ëÀ» È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.)
¿ÞÂÊÀÇ ±ÛÀÚ¸¦ ÀÔ·ÂÇϼ¼¿ä.
   

 



 
»çÀÌÆ®¸í : ¸ðÁö¸®³× | ´ëÇ¥ : ÀÌ°æÇö | °³ÀÎÄ¿¹Â´ÏƼ : ·©Å°´åÄÄ ¿î¿µÃ¼Á¦(OS) | °æ±âµµ ¼º³²½Ã ºÐ´ç±¸ | ÀüÀÚ¿ìÆí : mojily°ñ¹ðÀÌchonnom.com Copyright ¨Ï www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.