Ubuntu Server VM: copy paste?

55

10

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.

bukzor

Posted 2010-10-03T18:57:53.837

Reputation: 1 775

Answers

61

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

Posted 2010-10-03T18:57:53.837

Reputation: 611

Couldn't get it to work either on Ubuntu Server 16.04 no matter what, most likely it is tied to the X server like you suggest, so no-can-do with terminal only OSs. – Mahn – 2016-07-11T17:53:02.153

2What IP address and port would you use to connect via SSH if the virtualbox is on a localhost? – DPSSpatial – 2017-02-02T18:21:43.127

1

There are lots of questions and answers on other sites about how to configure Virtualbox so you can SSH into it. Here's a simple one that worked for me with a Windows host and a terminal-only Ubuntu Server guest inside Virtualbox

– user56reinstatemonica8 – 2018-01-02T21:35:07.940

This should be the accepted answer. – Ardee Aram – 2019-01-27T09:27:42.457

@DPSSpatial I just used the ifconfig command on my guest to know the ip-address to use for SSH. I did not specify any port, because upon checking with nmap, I got to know that the SSH service was running on port 22 (the default one). – Reeshabh Ranjan – 2020-02-01T18:25:51.127

2That's not a bad suggestion. In fact it's probably more efficient/responsive than using the VM window. – bukzor – 2011-02-24T05:32:36.950

1@James Brilliant idea !!! :) – TraderJoeChicago – 2012-03-30T08:16:03.193

ran into this issue myself, this is definitely the only way I have found to work around this – adeleinr – 2012-12-21T02:01:00.257

8

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

trigg3r

Posted 2010-10-03T18:57:53.837

Reputation: 81

See also cygwin, with apt-cyg (apt-cyg install openssh-server) – Jonathan – 2016-09-23T07:39:51.727

@JonathanLeaders You would only need a SSH client and not server on your Windows host. – phk – 2017-01-01T23:00:55.680

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!

user5753767

Posted 2010-10-03T18:57:53.837

Reputation: 11

Irony: shared folder in VirtualBox is even harder to setup than shared clipboard. – SOFe – 2019-07-17T05:38:59.897

0

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.

AsimRazaKhan

Posted 2010-10-03T18:57:53.837

Reputation: 230

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.

Shane Reustle

Posted 2010-10-03T18:57:53.837

Reputation: 164

-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

Posted 2010-10-03T18:57:53.837

Reputation: 16 645

1

The shortcut I'd expect to work is shift-insert. http://en.wikipedia.org/wiki/Cut,_copy,_and_paste#Common_keyboard_shortcuts

– bukzor – 2010-10-04T03:46:07.100

Not the point. This is a problem with the virtualization a guest additions. – GregB – 2013-04-08T21:58:38.620

-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!

brandon.holtsclaw

Posted 2010-10-03T18:57:53.837

Reputation: 26

3You are wrong. CTL+SHIFT+V is the keyboard shortcut for the Ubuntu terminal, but there is an issue with the guest additions in Ubuntu 12.04 which will cause copy/paste to periodically break in one, or both directions. – GregB – 2013-04-08T21:57:37.990