106
105

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

autossh で ssh 切断時に自動で再接続する

Last updated at Posted at 2013-02-21

ノートPCで作業してると、移動時ネットワークが切れて ssh セッションが切れ、仮想端末は screen/tmux で状態復元が可能ですが、port forwarding なんかを活用してる場合再接続がめんどくさかったりしますよね。あれ、切れてるジャン…みたいな。

そんな場面が多い場合、 autossh を使うと便利です。

brew install autossh

でインストールして

autossh -M 空きポート -f -C 接続先 ping -i 30 localhost

しておくとあら便利!自動で再接続してくれます。

なお、~/.ssh/config に

Host hostname.proxy
  HostName hostname
  DynamicForward 10023
  LocalForward localhost:6667 localhost:6667

とか、通常接続とは違う port forwarding 専用の設定を作っておくとわりと便利です。社内で定期的に出る話題なのでシェア!

あと Mosh の話しはきいてません!

106
105
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
106
105

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?