LoginSignup
35
36

More than 5 years have passed since last update.

autosshでsshを永続化(?)

Last updated at Posted at 2014-07-19

fuseモジュールが必要のため、OpenVZでは使えません。

rpm

mac

brew install autossh
autossh -M 0 -f \
 -NL 8080:localhost:8080 remotesrv
  • -f : バックグラウンド
  • -M : モニタポート(理解していないが0指定)
  • 後はいつもの。

動作テスト

  1. PCをネットから切断。
  2. sshが絶対に切れたと思う時間だけ待って再度ネットに接続。
  3. 10秒後位にsshがつながっていることを確認。

終了方法

killall autossh

便利に使うために

autoconnect.sh
#!/bin/sh

killall -9 autossh
killall -9 ssh
AUTOSSH="autossh -M 0 -f -o Compression=yes"

# alminium
$AUTOSSH -NL 8081:localhost:8081 remotesrv
# rdp1
$AUTOSSH -NL 3391:192.168.11.11:3389 remotesrv
# rdp2
$AUTOSSH -NL 3392:192.168.11.12:3389 remotesrv
# icinga
$AUTOSSH -NL 8082:localhost:80 remotesrv2

open -a "Google Chrome.app" $HOME/autoconnect.html
autoconnect.html
<style>
* {
  line-height: 2em;
}
</style>
<ul>
  <li><a href="http://localhost:8081/projects/myproject/issues?per_page=100">8081: remotesrv alminium</a>
  <li><a href="http://localhost:8081/jenkins/">8081: remotesrv jenkins</a>
  <li><a href="http://localhost:8082/cgi-bin/icinga/status.cgi">8082: icinga remotesrv2</a>
  <li>3391: rdp1</a>
  <li>3392: rdp2</a>
  • autoconnect.sh を実行。

モバイル環境で使ってみた

autosshが勝手に再接続してくれない(?)ので手動で./autoconnect.shを実行しています。
複数のportfowardingをやってくれる点で便利。

35
36
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
35
36