Can't seem to SSH into my CentOS Virtualbox?

8,455

In your screenshot, the host and the guest have the same IP. That doesn't seem right. If you've set your VM to use NAT, it will receive its own IP address. Port forwarding shouldn't be needed (unless you want to be able to connect to a service inside your VM through your hosts networking interface).

To determine your local IP address, run the following command inside a shell on your VM:

ip a
Share:
8,455

Related videos on Youtube

user1045696
Author by

user1045696

Updated on September 18, 2022

Comments

  • user1045696
    user1045696 over 1 year

    I can't seem to SSH into my CentOS VirtualBox 4.0 running on Windows 7 64-bit. SSHD is running. I've forwarded port 2222 on localhost to the virtual machine (port 22).

    enter image description here

    The network adapter is NAT because for some reason bridged refuses to start the virtual machine.

    Any ideas?

    • Oliver Salzburg
      Oliver Salzburg over 12 years
      Why did you forward any ports for this? If your virtual network is set up using NAT, your VM has its own IP address (and its own port 22).
    • user1045696
      user1045696 over 12 years
      @OliverSalzburg Really? I wasn't aware, how would I find the IP? Sorry, I'm quite new at this.
    • Fran
      Fran about 12 years
      @OliverSalzburg If his VM is setup to use NAT networking, then the only way for inbound connections to make it into the VM is via the Port Forwarding Rules. It's no different than if you have a NAT WiFi router at home. Inbound connections cannot get in. How could they? They would have to be addressed to a non-routable address (e.g., 192.168.3.4).
  • user1045696
    user1045696 over 12 years
    Hey, here's what ip a spits out: click I'm not entirely sure what to do with this?
  • Oliver Salzburg
    Oliver Salzburg over 12 years
    @Chintan Seems like the network adapter in your VM doesn't get an IPv4 address assigned at all. So either DHCP is disabled on your client, no DHCP server is available (which would be weird, because I assume VirtualBox acts as the DHCPd in this case).
  • user1045696
    user1045696 over 12 years
    The DHCP server should be enabled. I did some digging, found this: gyazo.com/df040ab2f3227d1c36704baa492cc9dc . So I'd assume the issue is that DHCP is disabled on my client? Any idea how to enable it? I'll keep looking into it, hopefully I find a solution!
  • user1045696
    user1045696 over 12 years
    Looks like I may have fixed it? gyazo.com/6f2d036e110965acb7b46887a7973a77 I assume 10.0.2.15 is the address I want to be sshing into?
  • user1045696
    user1045696 over 12 years
    If anyone finds this in the future and wants a solution, add BOOTPROTO=dhcp to /etc/sysconfig/network-scripts/ifcfg-eth0