Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Ubuntu virtualbox installed Ubuntu Server. My local machine has Ubuntu 12.04 OS. I need to copy files from the /var/www in the virtualbox Ubuntu Server in to my local machine. (My network settings in virtualbox is "Bridged Adapter" and it has a static IP: My local mchine IP is :

I tried following

scp -r test.php nilani@

It says

Port 22: No route to host
lost connection.

What is wrong here?

share|improve this question
Why don't you just share some folder from host Ubuntu? – c0rp Apr 3 '14 at 4:28
@c0rp: I have lot of files in /var/www folder which I need to copy to my local machine? – Nilani Algiriyage Apr 3 '14 at 4:32
It is not a problem, and it would be faster then copy through ssh. – c0rp Apr 3 '14 at 4:36
@c0rp: How can I share /var/www directory? – Nilani Algiriyage Apr 3 '14 at 4:39
up vote 0 down vote accepted

First make sure that you have openssh-server installed on your local machine, if not:

sudo apt-get install openssh-server

Then from your Virtual Machine:

scp /var/www/test.php nilani@

Alternatively you could do the other way around, this time from your local machine:

scp your_server_login@ .
share|improve this answer
Thanks, Managed to do it with openssh-server – Nilani Algiriyage Apr 3 '14 at 5:00
Don't forget to upvote my answer please. thanks – Sylvain Pineau Apr 3 '14 at 5:33

You can share some folder on your host machine. Host machine is your "real" Ubuntu where VirtualBox is installed.

For example:

Create folder in your $HOME

mkdir $HOME/vbox_share

Now using this answer share this folder to virtual machine. Don't forget to check automount option, and name it vbox_share

After that you should see this folder on your virtual Ubuntu in the /media/vbox_share


I forgot to say. If you will do this while your virtual Ubuntu is powered on, you should mount shared folder manually:

sudo mount -t vboxsf vbox_share /media/vbox_share

Now just copy /var/www

mkdir -p /media/vbox_share/var/www
cp -R /var/www /media/vbox_share/var/www
share|improve this answer
Thanks I'll try:) – Nilani Algiriyage Apr 3 '14 at 4:56
@NilaniAlgiriyage I update answer a little bit. You are welcome! – c0rp Apr 3 '14 at 5:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.