SSH from host machine Win7 to guest Fedora Machine in VirtualBox

8,934

Found the solution. The manual contains it all. Thanks Bender.

VBoxManage setextradata "Linux Guest"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "Linux Guest"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "Linux Guest"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
Share:
8,934
0fnt
Author by

0fnt

Updated on September 17, 2022

Comments

  • 0fnt
    0fnt over 1 year

    I'm using VirtualBox on Windows 7 to run Fedora 7. I seem to have my SSH on, as /sbin/service sshd status tells me. When I do an /sbin/ifconfig, I get this:

    eth0   Link encap:Ethernet  HWaddr 08:00:27:CF:5A:0B
           inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0

    I do an ssh 10.0.2.15 from inside Fedora, and connect back to the guest machine.

    When I do an ipconfig on my Windows machine, I get this information:

    Ethernet adapter VirtualBox Host-Only Network:
    
        Connection-specific DNS Suffix  . :
        Link-local IPv6 Address . . . . . : fe80::b42c:a852:a0e8:1636%19
        IPv4 Address. . . . . . . . . . . : 192.168.56.1
        Subnet Mask . . . . . . . . . . . : 255.255.255.0

    When I now use PuTTY, to connect to 192.168.56.1, it says connection refused. Connection to 10.0.2.15 times out.

    SSH service is running. I have disabled SELinux. Also, I have allowed ssh as a trusted service in system-configure-securitylevel. I have tried to switch the firewall completely, but it turns back on automatically.

    • Bender
      Bender over 14 years
      Did you read VirtualBox manual? What's your virtual machine's network adapter mode? If it's NAT, you need to set up port forwarding.
    • John T
      John T over 14 years
      If he's trying to ssh into a vm on his own box he doesn't need port forwarding at all.
    • Bender
      Bender over 14 years
      John, if you disagree I suggest you too read vbox manual.
  • 0fnt
    0fnt over 14 years
    I tried service network restart, but get 10.0.2.15 again, to which I failed to connect. When I set ip statically, my internet connection stops working from guest machine. Before I did anything, I tried to pint 192.168.56.1, and it worked perfectly. 10.0.2.15 gives a connection timeout. Can also ping my Windows 7 machine 172.24.1.203 from my Linux guest, when ip is 10.0.2.15, which is dynamically allocated.
  • Arjan
    Arjan over 14 years
    Most computers on the internet are in a different network than mine, but I can still connect to them? Even in my own network I have 192.168.x.x and 10.x.x.x mixed, but no problems connecting. (And ping responses may fail for other reasons?)