Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12365
  • 博文数量: 8
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 140
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-27 10:53
文章分类
文章存档

2013年(8)

我的朋友
最近访客

分类: 其他平台

2013-08-31 11:20:29

  

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

英文原文:Automatically restart SSH sessions and tunnels Using Autossh

 


本文由虫虫软件发出:
阅读(1036) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~