How can I ssh into a Virtual Box Windows 7 guest from a Linux host?

0

I've installed Cygwin on the guest and set up sshd. I can ssh localhost from within the guest.

The virtual machine is connected with a "NAT" adapter, and I've set up a port forwarding rule for the virtual machine that read as follows:

TCP 127.0.0.1 6666 10.0.2.15 22

but when I try to connect from the Linux host with:

$ ssh  -v -p 6666 bx@127.0.0.1
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

the command hangs with this output. What am I doing wrong?

PSkocik

Posted 2017-08-26T17:33:25.220

Reputation: 1 182

Answers

1

The NAT interfaces are pretty useless for anything beyond very simple internet connectivity in the virtual machine. Bridge the interface and get an addressable IP on the LAN, use a private interface, or a combination of NAT + one of the others.

TheCompWiz

Posted 2017-08-26T17:33:25.220

Reputation: 9 161

Thanks. Could you elaborate on that a little bit, please? If I change the Virtual Box network settings from "Attached to: NAT" to "Attached to: Bridged Adapter", the Port Forwarding button gets grayed out and the guest loses Internet connectivity, but nothing appears to be solved. – PSkocik – 2017-08-26T17:53:42.480

1Bridged, makes the interface behave like you plugged the VM directly into the network. You may need to renew the ip-address. Port-Forwarding is disabled, because you are no longer NAT'ing the connection... it will have it's own IP, and doesn't need NAT'ing. – TheCompWiz – 2017-08-26T17:59:27.093

0

I have found out that it does work fine the other way around so ssh from cygwin to the linux host. And so I am using that because it does not matter to me from which side I establish the connection.

Ondrej Popp

Posted 2017-08-26T17:33:25.220

Reputation: 1