Help us understand the problem. What is going on with this article?

autosshでsshを永続化(?)

More than 5 years have passed since last update.

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をやってくれる点で便利。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした