Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationEventAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.


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

ノート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 の話しはきいてません!

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
Help us understand the problem. What are the problem?