How to setting an ssh connection on a Virtualbox Ubuntu

Create an Ubuntu Virtualbox

Create a new Virtual Machine and check Create a new virtual disk

Name your virtualmachine, select Linux as OS type and Ubuntu (64 bit) as linux version.

Set the virtual RAM at half of the your real RAM, in my case I have 8gb on my laptop, so i give to virtual machine 4gb

Create a new virtual disk:

Select the source for install your Ubuntu OS, select VDI (VirtualBox Disk Image)

Select Dynamic allocation:

Set the size of your virtual Hard Disk and click on create:

Start your Machine:

Select the iso image of ubuntu (You must download it from ubuntu official web site).

Install Ubuntu following the installation wizard:

After have installed Ubuntu, login your virtualmachine ubuntu with username and password inserted during the installation:

Install openssh-server

sudo apt-get update
sudo apt-get install openssh-server

stop your virtualmachine.

Set the net of your virtualmachine:

click on settings & net:

Select NAT as connection and click on advanced, and set as in the picture below.

Click on port forwarding:

and set the SSH parameter:

Name: SSH

Protocol: TCP

Host IP:

Host Port: 2222

IP Guest: Empty

Port Guest: 22

Start your Virtual Machine:

When your VM is started, open your terminal and try to connect:

ssh yourusername@ -p 2222

now you shoud be inside your virtualmachine.

Problems and Possible Solutions:

If you can’t connect try to disable or change settings to ubuntu firewall:

sudo ufw disable

or try to connect to the ip of VM:

click on global tools:

Click on create:

Back to Settings > Network and select adapter 1

Select Adapter only Host.

go inside the VM and get the ip number with ifconfig and get ip address:


In my case the ip is

now from terminal I try to connect in ssh to the ip

ssh yourusername@

30s ad

Vue.js Essentials - 3 Course Bundle

Sıfırdan İleri Seviye Vue.JS Eğitimi ve Uygulama Geliştirme

Vue.js 2 Basics in just 1 hour FREE

Programador FullStack JS Vue Node: Proj Galeria Vídeo e CRUD

Learn by Doing: Vue JS 2.0 the Right Way


How to setting an ssh connection on a Virtualbox Ubuntu
1 Likes39.25 GEEK