2

I have virtualbox 5.1 installed on Ubuntu 16.04 OS. I am using it to set up a Ubuntu 16.04 Virtual Machine.

I have set up the VM using a .iso file of Ubuntu 16.04. I installed the guest editions from the 'Device' drop down menu and have enabled 'Bidirectional' option in the settings for both Shared Clipboard and Drop'n'Drop options.

With these settings, I am unable to copy/paste or drop files from host to guest or vice-versa. How do I resolve this as I need this functionality to transfer important files.

zingsy
  • 123

1 Answers1

0

This is not the best answer to your question because it ignores the problem and accomplishes transfers another way. Nevertheless, I'm posting this answer anyway because I've been in your shoes, and I typically resort to using the virtual network between VM and host to transfer files. Instead of wasting time trying to get vbox features to work, I just use netcat to perform an insecure file transfer. The fact that it's insecure would only matter if your VM is visible to your host's local network. By default, it uses NAT, so that fact that it's an insecure transfer is likely inconsequential.

Assumptions:

  • Default network settings (NAT, no virtual network customization)
  • Guest VM can see host computer at 10.0.2.2 (typical default for VirtualBox)

Getting the hosts virtual network IP: (Added 2017-05-06)

You could use your host's IP for whatever non-virtual network it's connected to, but I would advise against that for security reasons. Use the IP from the virtual network. It's safer.

In the virtual machine guest OS, open a terminal and run the following command:

route -n | grep -P "^0.0.0.0" | tr -s ' ' | cut -f2 -d ' '

The IP address that is returned by this command is the IP address you'll substitute below in the nc commands. Mine is 10.0.2.2

Host -> Guest file transfer:

  • On your host, run cat /your/file/to/transfer | nc -l 21435. Here, 21435 is the port to use. You can subsitute any unused port.
  • On the guest machine run nc 10.0.2.2 21435 > /your/file/to/save.

Guest -> Host file transfer:

  • On your host, run nc -l 21435 > /your/file/to/save.
  • On the guest machine run cat /your/file/to/transfer | nc 10.0.2.2 21435.

Regardless of the direction of the transfer, make sure you run the commands above in the order listed (for the direction in question). This is important because the first command starts a listening service to which the second command connects. After running the first command, the terminal will appear to become unresponsive. The program is running and listening on that machine. Once the second command is run on the other machine and the transfer completes, the terminals on both machines will "become responsive" again (ie. nc will exit).


To transfer multiple files, it may be easier to compress them all into a single archive file first.

I would not advise doing sensitive file transfers like this over a network that other parties might be able to eavesdrop on unless you were to take other means to encrypt the data.

b_laoshi
  • 4,660
  • 4
  • 25
  • 46
  • I have the default NAT setting, but the command to transfer using nc is unresponsive on host OS. Netcat is already present. Am I missing something ? – zingsy May 05 '17 at 09:04
  • When the command is run from the host (in either scenario) it will open in a listening mode. The terminal will appear to go unresponsive when in fact, it's just waiting for a client to connect. When you run the command on the guest machine, the file transfer will take place. Once file transfer is finished, both terminals (in guest and host) should be responsive once again. If both terminals sit unresponsive, and the file being copied has not appeared on the destination machine, it's likely the host isn't at 10.0.2.2. Let me know, and I'll edit the post with instructions to find the host's IP. – b_laoshi May 05 '17 at 13:36
  • When i do an ifconfig on the guest, then the inet address for 'enps08' is 10.0.3.15. I used this address in the command to receive the file in the guest but in vain. – zingsy May 06 '17 at 07:56
  • @zingsy, that won't work. I'll update my post to include steps on how to find the IP address of the host that the VM is able to see. – b_laoshi May 06 '17 at 11:32