ºìÁªLinuxÃÅ»§
Linux°ïÖú

ʹÓÃautossh×Ô¶¯ÖØÆôSSH»á»°ºÍͨµÀ

·¢²¼Ê±¼ä:2014-07-05 10:18:48À´Ô´:ºìÁª×÷Õß:velcbo
autossh ÊÇÒ»¸öÓÃÀ´Æô¶¯ ssh ²¢½øÐÐ¼à¿ØµÄ³ÌÐò£¬¿ÉÔÚÐèÒªÊ±ÖØÆô ssh£¬ÀýÈç³ÌÐò¹Òµô»òÕßÊÇÍøÂç³öÏÖÎÊÌâ¡£ÆäÁé¸ÐºÍ»úÖÆÀ´×ÔÓÚ rstunnel (Reliable SSH Tunnel). autossh 1.2 µÄ·½·¨ÒѾ­¸Ä±ä£ºautossh ʹÓà ssh À´¹¹ÔìÒ»¸ö ssh ÖØ¶¨ÏòÑ­»·£¨±¾µØµ½Ô¶³ÌºÍÔ¶³Ìµ½±¾µØ£©£¬È»ºó·¢ËͲâÊÔÊý¾Ý²¢»ñµÃ·µ»Ø½á¹û¡£

autossh 1.3 Ôö¼ÓÁËÒ»¸öÐµķ½·¨£º¿ÉÖ¸¶¨Ô¶³Ì echo ·þÎñµÄ¶Ë¿ÚÓÃÓÚ·µ»Ø²âÊÔÊý¾Ý·¢Ëͽá¹û¡£Õâ¸ö±ÜÃâÎÕÊÖ½×¶ÎÒÔ¼°ËùÓÐÔ¶³Ì»úÆ÷¶Ë¿ÚµÄ³åÍ»ÎÊÌâ¡£¶øÀ쵀 loop-of-forwardings ·½·¨ÒÀÈ»¿ÉÓá£
ÔÚ Ubuntu Éϰ²×° autossh

´ò¿ªÖÕ¶Ë´°¿Ú²¢ÔËÐÐÒÔÏÂÃüÁî

sudo apt-get install autossh

Autossh Óï·¨

autossh [-V] [-M port[:echo_port]] [-f] [SSH_OPTIONS]

ÔÚÆô¶¯Ê±Æô¶¯ ssh ͨµÀ

ÎÒÃÇ¿ÉÒÔʹÓà upstart À´ÔÚ Ubuntu ÏÂÆô¶¯ ssh ͨµÀ£¬Ö»ÐèÒª½«ÈçÏ autossh.conf Îļþ·ÅÔÚ /etc/init Ŀ¼¼´¿É¡£

# autossh startup Script

description "autossh daemon startup"

start on net-device-up IFACE=eth0
stop on runlevel [01S6]

respawn
respawn limit 5 60 # respawn max 5 times in 60 seconds

script
export AUTOSSH_PIDFILE=/var/run/autossh.pid
export AUTOSSH_POLL=60
export AUTOSSH_FIRST_POLL=30
export AUTOSSH_GATETIME=0
export AUTOSSH_DEBUG=1
autossh -M 0 -4 -N USER@HOSTNAME -D 7070 -o "ServerAliveInterval 60¡å -o "ServerAliveCountMax 3¡å -o BatchMode=yes -o StrictHostKeyChecking=no -i SSH_KEY_FILE_PATH
end script

À´Ô´£ºoschina.net ×÷ÕߣººìÊí
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ