How to SCP a file from Mac -> Ubuntu VirtualBox?

51,198

Solution 1

Put network settings from NAT to bridged adapter in Virtualbox settings for that machine. Then your virtual machine will be in local network with your host machine. It will probably get the IP from modem if DHCP is enabled, then scp to that machine.
You also need to have ssh-server installed on Ubuntu machine:
sudo apt-get install openssh-server
That should work: scp file host:/some/directory

Solution 2

User port forwarding
- With guest running, go to VirtualBox settings/network
- Click Port Forwarding
- Name "ssh", protocol TCP, Host port = 3022, Guest port = 22
Then, on the host,

scp -P 3022 myFile localhost:

Solution 3

After having installed Guest Additions you will be able to create shared folders for access from both, host and guest OS. Any directory on the host can be used for this. The shared folder needs to be mounted on the guest OS by:

sudo mount -t vboxsf [-o OPTIONS] sharename mountpoint

See also this answer on usage of shared folders. To make shared folders acessible on each boot of the guest os, you need to add the mounts to the guest fstab.

Alternatively you can also access directories from the host by adressing them using network shares.

Solution 4

Adding to enedene's answer:

change the adapter settings on your Oracle VM vitualbox to Bridged Adapter On the top left side of you Virtualbox screen click on "Machine" Click on Machine>Settings>Network>

Change the "Attached to:" to "Bridged Adapter" then Click "Ok"

Reset the Virtualbox (Click Machine>Reset)

Once it comes up do an ifconfig in terminal and use the new ip address for SCP

Solution 5

If you install the Virtualbox Guest Addons you can create a shared folder. Then use vboxmount (as root) under Ubuntu to mount the shared folder. Afterward, copy normally (cp).

If you actually need to use scp, let me know. I will dig up that information.

Share:
51,198

Related videos on Youtube

coffee-grinder
Author by

coffee-grinder

I love StackOverflow!

Updated on September 18, 2022

Comments

  • coffee-grinder
    coffee-grinder over 1 year

    I have a Mac (OS X) and a VirtualBox running Ubuntu.

    I want to SCP a 500mb file from the Mac to the VirtualBox. How do I do this? (Probably something to do with /etc/hosts?)

  • Takkat
    Takkat almost 13 years
    can you give us more details on how to use vboxmount?
  • Azizur Rahman
    Azizur Rahman almost 13 years
    Take a look at Shared folders for details.
  • cdahms
    cdahms over 3 years
    Needing to install openssh-server on the host is the key step !!
  • Cheetaiean
    Cheetaiean over 2 years
    If there is a password issue, simply add the user name of the Ubuntu Vm to the command, i.e. scp -P 3022 myFile user@localhost: