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 1 year has passed since last update.

踏み台サーバーを経由した多段SSHのconfigの書き方

Last updated at Posted at 2022-01-31

初めに

自分の備忘録として、パスワード認証で踏み台サーバーを経由したSSH接続に少し困ったので書いておきます。

自分がはまった部分

以下のようなconfigを書いてSSHコマンドを叩いた所、ssh: Could not resolve hostname ssh: でエラーになりました。

.ssh/config
# 踏み台サーバー
Host step-server
HostName hoge
User hoge
Port hoge
IdentitiesOnly no
TCPKeepAlive yes

# SSHしたいサーバー
Host target-server
HostName hoge
User hoge
IdentitiesOnly no
TCPKeepAlive yes
ProxyCommand ssh -W %h:%p step-server

解決策

OepnSSH 8.0よりも前のversionを使用している場合にconfigに絶対パスを使用しなければいけないらしい。
(この問題はOpenSSHのバグで、OpenSSH 8.0以降では修正されているようです)
具体的に以下のようにconfigを書いたら動きました。

.ssh/config
# 踏み台サーバー
Host step-server
HostName hoge
User hoge
Port hoge
IdentitiesOnly no
TCPKeepAlive yes

# 目的のサーバー
Host target-server
HostName hoge
User hoge
IdentitiesOnly no
TCPKeepAlive yes
ProxyCommand C:\Windows\System32\OpenSSh\ssh.exe -W %h:%p step-server # 絶対パスに変更

参考文献

以下の記事に助けてもらいました。
https://www.suzu6.net/posts/205-ssh-config-proxycommand-windows10/

何か修正した方が良いこと等、なんでもコメント頂けると幸いです。

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?