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?

  • 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

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@ .
  • 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
  • @NilaniAlgiriyage I update answer a little bit. You are welcome! – c0rp Apr 3 '14 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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