0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SSHのプロキシと接続の維持を設定してQOLを上げる

Last updated at Posted at 2025-10-19

SSHのKeepAlive設定

~/.ssh/config に下記を追加

Host myserver
    HostName 192.168.11.16
    User your_name
    IdentityFile path_to_secret_key
    ServerAliveInterval 15
    ServerAliveCountMax 2

意味

ServerAliveInterval 15:

15秒ごとに、サーバーへ「まだ生きてるよ」サインを送信

ServerAliveCountMax 2:

後続2回応答がなければ、接続を切る

利点

短期的なネット切れでも接続が維持される

スリープ後も再接続の必要がない場合が増える

Proxy(踏み台)を使う構成の場合

ローカルネットワーク内のサーバーにアクセスするために、踏み台サーバーを経由することがある。その場合も ~/.ssh/config で構成しておくと便利。

個人的には大学のサーバーにアクセスするときやproxmoxからVM上にアクセスするときに楽になる

Host by_hoge
    HostName hoge_addrs
    User hogehoge
    IdentityFile your_secret_key
    ServerAliveInterval 15
    ServerAliveCountMax 2


Host to_hoge
    HostName to_hoge_addrs
    User hoge
    IdentityFile your_secret_key
    ProxyJump by_hoge
    ServerAliveInterval 15
    ServerAliveCountMax 2

この設定により、ssh to_hoge だけで踏み台経由の接続が簡単に行える。KeepAlive設定もそれぞれのホストに対して有効になる。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?