![Linux ホストから Virtual Box Windows 7 ゲストに SSH 接続するにはどうすればよいでしょうか?](https://rvso.com/image/1539551/Linux%20%E3%83%9B%E3%82%B9%E3%83%88%E3%81%8B%E3%82%89%20Virtual%20Box%20Windows%207%20%E3%82%B2%E3%82%B9%E3%83%88%E3%81%AB%20SSH%20%E6%8E%A5%E7%B6%9A%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%81%8B%3F.png)
ゲストに Cygwin をインストールし、sshd を設定しました。ssh localhost
ゲスト内から実行できます。
仮想マシンは「NAT」アダプタに接続されており、仮想マシンのポート転送ルールを次のように設定しました。
TCP 127.0.0.1 6666 10.0.2.15 22
しかし、Linuxホストから次のように接続しようとすると、
$ ssh -v -p 6666 [email protected]
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 6666.
debug1: Connection established.
debug1: identity file /home/pjmp/.ssh/id_rsa type 1
debug1: identity file /home/pjmp/.ssh/id_rsa-cert type -1
debug1: identity file /home/pjmp/.ssh/id_dsa type -1
debug1: identity file /home/pjmp/.ssh/id_dsa-cert type -1
debug1: identity file /home/pjmp/.ssh/id_ecdsa type -1
debug1: identity file /home/pjmp/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/pjmp/.ssh/id_ed25519 type -1
debug1: identity file /home/pjmp/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
コマンドはこの出力でハングします。何が間違っているのでしょうか?
答え1
NAT インターフェイスは、仮想マシンでの非常に単純なインターネット接続以外ではほとんど役に立ちません。インターフェイスをブリッジして LAN 上でアドレス指定可能な IP を取得するか、プライベート インターフェイスを使用するか、NAT と他のインターフェイスのいずれかを組み合わせて使用します。
答え2
逆に、cygwin から Linux ホストに ssh すると正常に動作することがわかりました。どちら側から接続を確立しても問題ないため、これを使用しています。