LoginSignup
0
0

More than 5 years have passed since last update.

sshによる多段階接続のconfig

Last updated at Posted at 2018-11-06

N番煎じだが、どこで見かけたか忘れるので自身の備忘録。

前提条件

  • Local -> Remote01 -> Remote02 こういう接続をssh Remote02のコマンド一発でしたい。
  • Local -> Remote01Remote01 -> Remote02の接続が鍵認証で出来ること。
  • 接続には鍵認証を利用し、秘密鍵はLocalにsecret_key01secret_key02として、~/.ssh下に保存されているとする。
    • Local -> Remote01secret_key01
    • Remote01 -> Remote02secret_key02

configファイルの記述

ProxyCommandを組み合わせると実現できる。.ssh/configに次のように追記する。

Host Remote01
    HostName example01.com  # remote01 のIP/Host name
    IdentityFile ~/.ssh/secret_key01
    User user01

Host Remote02
    HostName example02.com  # remote02 のIP/Host name
    IdentityFile ~/.ssh/secret_key02
    User user02
    ProxyCommand ssh Remote01 -W %h:%p
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