Wednesday, April 9, 2014

autosshで自動再接続とポートフォワーディング

別にターミナルを一つ専有してもいいのに無駄に -f コマンドとかつけちゃうメモばかりをネットで見つけるのでここに書いておく

基本的にautossh用のオプションは -M <port> のみでOK
そこにsshの -C (compression) -N (no execute command) -L (Local port forwarding) で大体したいことが出来る

例:

autossh -M 50000 -C -N -L<local port>:<dest ip on remote>:<dest port> <ssh server>

いやむしろ -C -N も煩わしいって人は

autossh -M 50000 -L<local port>:<dest ip on remote>:<dest port> <ssh server>

いや、ポートフォワーディングしたいんだから~/.ssh/configにもう-Lの指定はしてるでしょ、と買って人は

autossh -M 50000 <ssh server>

これでいいんですよ。
そもそも -f で裏に追いやってあとで使ってるの忘れたらいやじゃないですか。なんでみんな -f しようとするの。

No comments:

Post a Comment