Can't SSH to VM - I've tried many things with no luck

5,238

Solution 1

You need to do one of the following:

  1. Setup your VM with bridged networking mode.
  2. Setup port forwarding on in Virtual Box to accept some port (probably not 22) on 192.168.56.1 to forward to 22 on the 10.x.x.x ip your VM has.

Here is a decent reference. http://www.howtogeek.com/122641/how-to-forward-ports-to-a-virtual-machine-and-use-it-as-a-server/

Solution 2

Are you sure that 192.168.56.1 is the right IP? I'd have thought .1 would probably be the host system rather than the VM?

10.0.2.0 is a network address. Your VM will not have that address, and neither will the Host system. Each will presumably have an IP on that network though, with the last number of that address being something other than 0

Since you can log in OK via the console, do that and use ip addr show | grep inet to find out what its network addresses are.

Share:
5,238

Related videos on Youtube

dspacejs
Author by

dspacejs

Passionate and well-rounded full-stack engineer. Skilled with Python, Django, React, and plenty more.

Updated on September 18, 2022

Comments

  • dspacejs
    dspacejs over 1 year

    I've been trying to SSH to my virtual machine with no luck over the past 2 hours.

    I can login directly to my VM successfully - but I can't SSH to it.

    Attempt 1:

    In VirtualBox, I have setup a host-only network. If I SSH to the IP for this using ssh [email protected] -p22, the following occurs:

    A password prompt shows up, and my user's password does not work. After 3 failed attempts I receive the following error:

    Permission denied (publickey,keyboard-interactive).
    

    Attempt 2:

    I also have a NAT set up in VirtualBox with the CIDR 10.0.2.0/24. If I try and SSH into it using ssh [email protected] -p22, nothing happens, and it eventually times out.

    If I ping this IP, it also times out with each ping:

    Request timeout for icmp_seq 0
    Request timeout for icmp_seq 1
    ...
    

    More Details:

    I have PasswordAuthentication set to yes in /etc/ssh/sshd_config.

    I've also checked the contents of /var/log/secure, which has no output from tail -f when attempting to SSH into the VM.

    I'm really not sure what the problem is, or what to do to solve it. Any help would be appreciated! Thanks.

    • Eddie Dunn
      Eddie Dunn over 8 years
      Is your Host machine also linux?
    • Eddie Dunn
      Eddie Dunn over 8 years
      Also, Where are you trying to connect from? You will definitely not be able to ping anything behind a NAT. You can setup port forwarding to get through it.
    • dspacejs
      dspacejs over 8 years
      my VM is CentOS, and I'm on a Mac
  • dspacejs
    dspacejs over 8 years
    Okay, so I've run that command. The only two useful outputs are: inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3 and inet 172.17.42.1/16 scope global docker0. When I try to SSH into either of those three IPs it simply times out. Also, how am I supposed to tell when one is the correct IP to SSH into?
  • mc0e
    mc0e over 8 years
    docker0 will be local to that machine. Use Use 10.0.2.15. It might be clearer to you without the grep. New check ping, and check that you can ssh to 10.0.2.15 from within the VM. Also /var/log/secure might be mo re useful now.