An easy way to SSH into a Gnome Boxes OS

Recently, we set up an Ubuntu Server in a Gnome Boxes virtual machine. We wanted to perform an ssh connection into it to make administration easier. In the properties of the VM that are visible from the GUI, there was no option to edit the network cards and set up a virtual network between the host and the virtual machine.

To allow ourselves to perform the ssh connection, we decided to go with the option of reverse ssh tunneling. To do so, we needed to install and start the ssh server.

After that, we got the IP of the host machine.

Then, we used the terminal of the virtual machine to execute the following ssh command:

ssh -N -T -R 22222:localhost:22 [email protected]_machine_ip;

That created a connection to the host machine and blocked the terminal as expected since it was an active application.

Finally, from the host, we executed the following to ssh into the virtual machine:

ssh -p 22222 [email protected];

The biggest disadvantage of this method is that you need to enable ssh on your host machine.

The biggest advantage is the ease with which anyone can set it up.

Notes on the ssh parameters:

-N Do not execute a remote command. This is useful for just forwarding ports.

-T Disable pseudo-terminal allocation.

-R remote_socket:host:hostport Specifies that connections to the given TCP port or Unix socket on the remote (server) host are to be forwarded to the local side.

This post is also available in: Greek

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.