Cannot SSH to VM

Ok, here's how it finally came together:

One of my coworkers recalled that the disk image "might not have a second interface enabled." Since the VBox is set up with NAT as adapter one and Host-only as adapter two, you need to have eth0 and eth1 set up on the disk image. We did not.

To do this:

  • verify that ifconfig |less does not have both eth0 and eth1 listed.
  • cd /etc/sysconfig/network-scripts/
  • cp ifcfg-eth0 ifcfg-eth1
  • cp ifcfg-eth0.bak ifcfg-eth1.bak
  • edit the files and remove anything with HWaddr and change eth0 to eth1 ifcfg-eth1
  • ifup eth1
  • then run ifconfig and take the inet addr of eth1, which was a different IP for me. I'm now working with 192.168.56.101.
  • do init 6 to restart and make sure that eth1 starts automatically now.
  • log in from host: ssh [email protected]

None of the edits in the question above were actually my problem, but it's all good debug info!!

Cheers,
Ken


It looks like the ssh daemon is using IPv6 (from the output of lsof -i :22) while you are trying to connect with IPv4. The system won't know how to route the traffic.

I am not sure about the IP conflict you are seeing, but would suggest trying the following:

  1. Disable IPv6

    Add the following to /etc/sysctl.conf

    net.ipv6.conf.all.disable_ipv6 = 1
    net.ipv6.conf.default.disable_ipv6 = 1
    

    Disable IPv6 on the running system

    sysctl -w net.ipv6.conf.default.disable_ipv6=1
    sysctl -w net.ipv6.conf.all.disable_ipv6=1
    

    Disable iptables for IPv6

    chkconfig ip6tables off
    
  2. Restart something!

    You will have to restart the ssh daemon or the OS for the changes to take effect.

    So restart sshd

    service sshd restart
    

    Or restart the OS itself

    init 6
    

Don't forget you may not have a route to the host and may think about using bridged mode so your DHCP server can hand out a correct address.

You may also want to read the CentOS Wiki for more info about disabling IPv6

Tags:

Ssh