1

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.

3
  • Is your Host machine also linux?
    – Eddie Dunn
    Dec 11, 2015 at 15:01
  • 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.
    – Eddie Dunn
    Dec 11, 2015 at 15:07
  • my VM is CentOS, and I'm on a Mac
    – Daniel
    Dec 12, 2015 at 1:03

2 Answers 2

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/

0
1

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.

2
  • 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?
    – Daniel
    Dec 12, 2015 at 1:11
  • 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.
    – mc0e
    Dec 13, 2015 at 1:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .