Connect to VirtualBox Linux Node using PuTTY
When you run a Linux command-line only virtual machine in VirtualBox, the VirtualBox window can be difficult for prolonged use. For example, there is no copy-and-paste, and no scrolling through past terminal output. Also you cannot change the terminal size and the fonts (when zoomed) are poor quality. To overcome this, I commonly use an external application to SSH into the Linux machine, allowing me to take advantage of the GUI/Terminal capabilities of that external application.
On Linux (or OSX) hosts, a SSH client is built-in. From a terminal on the host, ssh can be used to connect to the virtual machine. On Windows hosts, PuTTY is a good choice.
However for SSH to work, the virtual machine must be running a SSH server and VirtualBox must be configured to accept connections (i.e. port forwarding). Luckily when using virtnet Linux nodes, both conditions are met.
IP Address and Port of virtnet Nodes
Each node in virtnet is configured to run a SSH server (on the standard port 22) and VirtualBox is configured to port forward from another port to 22. The scheme used in virtnet is that the external port is 22 followed by the node number. For example:
- node1 uses port 2201
- node2 uses port 2202
- node3 uses port 2203
To connect from host to virtual machine, the destination IP address is 127.0.0.1 (or localhost).
Connecting via Linux Hosts
To connect to node1, open a Terminal and run the following command:
ssh -l network -p 2201 127.0.0.1
To connect to a different node, change the port number from 2201 to 22xx, where xx is the node number.
Connecting via Windows Hosts
Assuming PuTTY is installed, start it and set the following in the PuTTY Configuration window if wanting to connect to node1:
- Host Name (or IP Address): 127.0.0.1
- Port: 2201
Then press the Open button. To connect to a different node, change the port number from 2201 to 22xx, where xx is the node number.
You may be warned about the server's host key. Since you are connecting within your own computer (and not across a network), there is very little chance of an attack, so you can trust the key. Click Yes to proceed.
Created on Thu, 02 Mar 2017, 4:50pm
Last changed on Thu, 02 Mar 2017, 4:50pm