LoginSignup
18
16

More than 5 years have passed since last update.

sshの設定をconfigに書いたらssh接続がラクになる

Last updated at Posted at 2015-12-01

ssh接続のショートカット

ssh -i .ssh/aws.pem -p 22 ec2user@11.111.111.1

ssh接続するときにこんな感じで書くのめんどくさくないですか?
解決策として.ssh/configに設定を書けばラクになります。

vim .ssh/config

configに以下を記入

Host pro_aws
  Hostname 11.111.111.1 //ipアドレス
  Port 22 //port番号
  User ec2-user //ユーザー名
  IdentityFile .ssh/aws.pem
ssh pro_aws

これでサーバーに入ることができる。

おまけ(ssh 接続をタイムアウトの設定)

SSH(SSHのクライアント)の設定を変更する

vim .ssh/config

configに以下を記入

ServerAliveInterval 60
ServerAliveCountMax 3

ServerAliveInterval 60 に設定すると 60秒毎にサーバーにメッセージを
送り、ServerAliveCountMax のデフォルト回数である 3回まで繰り返す。
つまり、サーバーが応答しなくなった後 180秒後に接続を切断する。

18
16
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
18
16