75

I've installed Ubuntu Server under Virtualbox just to get a nice little shell. I've also installed the VirtualBox "Guest Additions" and set "Shared Clipboard: Bidirectional".

I still can't seem to get any copy-paste working. Am I missing something here?


I've installed gpm which gives mouse support in server mode (no X), and allows copy-paste using the mouse, but still the VirtualBox integration doesn't work.

Nifle
  • 34,998
bukzor
  • 2,170
  • 2
  • 16
  • 22

8 Answers8

82

Just trying this myself. Couldn't get it to work with gpm and a console only guest.

I strongly suspect that the clipboard integration rely's on having a running X server in the Guest.

A work-a-round is to install openssh-server on the guest and ssh using a terminal from your host to the guest. Then you have 'clipboard integration'

James McDonald
  • 821
  • 6
  • 3
10

Try to use PuTTY and connect via SSH to your virtual Linux system.

030
  • 2,808
  • 9
  • 29
  • 40
trigg3r
  • 101
1

I came up with a different workaround. Open a shared folder, and create an executable script in the shared folder. Put "#!/bin/bash" (or whatever/wherever shell you want to use), followed by the command(s) you want to execute. Like this:

#!/bin/bash
cp foo bar
echo 'copied foo to bar'

Just replace "cp foo bar" with the long complicated string you wanted to cut and paste.

Depending on what you're doing, you might have to source the script rather than running it directly:

source ./myscript

EDIT: Oops! I forgot to add that you have to change the line endings from Windows-style to Unix-style line endings. In Emacs you can use

M-x set-buffer-file-coding-system

while in vim it would be

:set ff=unix

Sorry!

1

If you're running a Server in a VM , then why don't you just ssh into the VM and use the terminal?

Think about it. It's a server with no graphical interface.

If you only had the sever version installed on a actual computer instead of the VM would you have been able to copy paste into it's command line prompt? You have no multitasking available in the same TTY unless you use some multimplexer like "screen" or "tmux" or a software such as "gpm" as v3.xx suggested.

1

I just found you can transfer files between host and guest using netcat. It should be preinstalled in Ubuntu.

Let the host has IP address 10.0.1.12 and I randomly choose port 8080 to communicate.

Guest → Host

On guest (mine is macOS 15, the port might be specified using -p 8080 in other OS):

nc -l 8080 < my-file.txt

On host (mine is Ubuntu 24.04)

nc 10.0.1.12 8080 > my-file.txt

then Ctrl+C to kill the netcat (there is no progressbar and it does not quit on completion)

Host → Guest

On guest

nc -l 8080 > my-file.txt

On host (mine is Ubuntu 24.04)

nc 10.0.1.12 8080 < my-file.txt

Using ssh could be problematic since the host is behind NAT and you have to forward ports. For some simple transfers this could be the most simple solution :)

Note that this is not limited to guest / host. You can do that between any computers on network. Just be warned that it sends data without any encryption.

0

This is probably not a "solution", but it's how I was able to get some data off my ubuntu server VM. I set up a simple php file upload script on one of my servers, then shot the file up to it via curl. As soon as I was done I removed it.

-2

I don't think that you will be able to copy/paste in Ubuntu Server, mostly because:

  1. If you try to do Ctrl+V, the OS will see that as a ^V control sequence.
  2. You can't do a copy/paste with a right-click menu as there are no mouse daemons that support that. (As far as I know anyways, someone feel free to correct me.)
Wuffers
  • 19,619
-3

You need to use CTL+Shift+V to paste, copy as normal in the Host, and back in the VM add Shift as well if you wish to copy, so CTL+SHIFT+C ( then Cut with same + X ).

Cheers!