How Do You Use Putty To Connect To A CentOS Server (A Guest VM running on Oracle VirtualBox on a Windows Host)?

Problem scenario:  You have a Windows 7 host with Oracle VirtualBox.  You have a guest CentOS Linux virtual server.  How do you connect to a CentOS VM using networking?

Miscellaneous:  If you are looking for directions on how to give a Linux guest access to the Internet, these directions will work (assuming the host is running Windows).

Solution
#1  In Oracle VirtualBox go to Devices -> Network -> Network Settings.  For Adapter1 have the "Attached to" drop down be configured for "NAT."  Go to "Advanced" and check the box for "Cable Connected."  Click "Ok."

#2  Go to the Linux CentOS server.  Enter this command:

ip addr show | grep inet | grep -v inet6 | grep -v 127.0.0.1 | awk '{print$2}'

Make a mental note of the IP address you find (e.g., 10.0.2.14), but you can ignore the CIDR (e.g., /24).

#3  In Oracle VirtualBox go back to Devices -> Network -> Network Settings.  For Adapter1 go to "Advanced" and click the button for "Port Forwarding."  If you find everything has been preconfigured, make a mental note of the Guest IP address and go to step #4.  Otherwise click the icon of the green diamond with a green plus sign to add a rule.  Make sure the rule, under any name, has the following settings:

Protocol: TCP
Host IP: 127.0.1.1
Host port: 22
Guest IP: 10.0.2.14
Guest port: 22

"10.0.2.14" is just an example of a guest IP address.  The Guest IP you should use should be the IP address found in step #2 above.  Similarly, "127.0.1.1" is just an example of a Host IP address.  If you have two or more guest machines, you may want to use "127.0.2.1" for one of the servers.  This way you could connect to each of them with Putty.

Click "OK" and click "OK" again.

#4  Open Putty on the Windows host.  Connect to the guest IP address -- in the example above for one server, it would be 127.0.1.1.

Leave a comment

Your email address will not be published. Required fields are marked *