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?

More than 3 years have passed since last update.

ssh接続が勝手に切れて欲しくない時 (CUI)

Last updated at Posted at 2020-04-28

ssh接続が勝手に切れて欲しくない時 (CUI)

~/.ssh/config を書き換えるといいみたい。
「config」とは「設定」という意味。

しかし、私の .sshの中にconfigが無かったので作成する必要があった。

vi config

で、configを作成と同時に編集。中身は

# ~/.ssh/config

Host 任意なホスト名(自分で勝手に決めていい)
    HostName ホストのアドレスかIPアドレス
    User ログインユーザ名
    #Port
    ServerAliveInterval 180
    ServerAliveCountMax 60
    IdentityFile ~/.ssh/id_rsa
    IdentitiesOnly yes

と書いた。これで、
ssh 任意なホスト名
と打つだけで入れる。

 今回の目的のssh接続切れなくするための部分は
ServerAliveInterval 180
ServerAliveCountMax 60
応答がなくなってから、180秒ごとに信号を送り、最大60回まで送るので、1時間半は勝手に接続切れないはず。
多分、CountMaxを設定しなかったら延々送り続けるみたい。

IdentityFile
IdentitiesOnly
で公開鍵を自動で認識してくれる。
ただ、パスワードの方はconfigで設定できないから、毎回打つしか無いみたい。セキュリティー上そちらの方が良い。

Portは、なんとなく入れておいた(コメントアウトで意味無いけど)。デフォルトは22らしい。

※あとは、パソコン自体の省エネ設定で、「ディスプレイがオフのときにコンピュータを自動でスリープさせない」にチェックを入れておけば完璧(Mac)。

参考にさせて頂いたURL(もっと色々記載されている)
https://qiita.com/0084ken/items/2e4e9ae44ec5e01328f1
https://qiita.com/seiyaan/items/d9030538833b3903f795
https://qiita.com/oohira/items/7deae31469cfbbd740c1
https://qiita.com/passol78/items/2ad123e39efeb1a5286b

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?