LoginSignup
7
7

More than 5 years have passed since last update.

多段sshの設定

Last updated at Posted at 2013-11-11

シナリオ

localからgwを経由してtargetにsshする。

手順

  1. 鍵認証
    localでssh-keygenし、公開鍵をgwとtargetの双方のauthorized_keysに追加する。

  2. config設定
    localの$HOME/.ssh/configに以下を設定する。

Host gw
  HostName xxx.xx.xx.xxx
  User xxx

Host target
  HostName xxx.xx.xx.xxx
  User xxx
  ProxyCommand ssh gw nc %h %p

これで、ssh targetできるようになった。scpも可能。
targetにログインするユーザーとlocalのユーザーが違う場合はUserを必ず設定すること。

また、sshのバージョンによってはncの代わりに-Wオプションで同じことができるらしい。

7
7
2

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