How to SSH into Centos in VirtualBox

How to SSH into Centos in VirtualBox

Today I created a CentOS virtual machine in VirtualBox on my Mac for testing Hadoop purpose, however, I was not able to SSH into the newly created virtual machine, and SSH command returned timeout error:
$ ssh [email protected]
ssh: connect to host 10.0.2.15 port 22: Operation timed out
The output of “ip addr show” in the CentOS: centos-ip-address To fix the issue, I did the following: 1. Go to Devices > Network > Network Settings 2. Click on “Port Forwarding” 3. Then enter the details similar as below: virtualbox-network-settings I did not need to restart the VM, and I just ran the following SSH command from host, and issue resolved:
$ ssh -p 2222 [email protected]
The authenticity of host '[127.0.0.1]:2222 ([127.0.0.1]:2222)' can't be established.
ECDSA key fingerprint is SHA256:QWANQHt0hrV+l98si9RT1u5r0H9Q6A/GCe5jR+MQbHs.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts.
[email protected]'s password:
Last failed login: Wed May 25 15:26:45 AEST 2016 from 10.0.2.2 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Wed May 25 15:22:16 2016 from localhost

4 Comments

  1. Billy E

    This worked great! Any advice or maybe a walk-thru like this for doing the same thing but on another computer in my network?

    Running Ubuntu with VirtualBox that’s running CentOS7 – I want to SSH into it from my Windows machine.

Leave a Reply

Your email address will not be published.

My new Snowflake Blog is now live. I will not be updating this blog anymore but will continue with new contents in the Snowflake world!