I have Ubuntu 11.04 desktop and a 11.04 VPS server.

After replacing vim with vim-gtk (I don't need GUI though), I'm able to use the system's clipboard in vim. I'd like to use the same feature in Ubuntu server, but it looks like it doesn't work with ssh -X.

Is there some way I can enable that feature or do I need to use nano for that?


1 Answer 1


The "clipboard" is a feature of X11, so you will need to enable "X11 forwarding" for the SSH connection in "trusted" mode:

$ ssh -Y myserver

(By default, X11 is forwarded in "untrusted" mode, which is somewhat too restrictive. -Y disables the restrictions.)

Also make sure the server has xauth and a X11-capable version of vim installed. You can use xsel -o and xsel -o -b to verify that the clipboard can be accessed.

To make it permanent, add the following to your local ~/.ssh/config:

Host myserver
    ForwardX11 yes
    ForwardX11Trusted yes
  • 1
    I'm using vim-gtk in server and I can see using "vim --version" that X11 is enabled. There is nothing about xauth through. This is what I get: $ xsel -o xsel: Can't open display: (null) : Success
    – jaz
    Aug 23, 2011 at 12:38
  • 1
    "sudo apt-get install xauth" did the trick.
    – jaz
    Aug 23, 2011 at 14:23
  • For whomever it is useful for: this worked for me, but only with the + register, not the * register. Your mileage may vary.
    – Walt W
    Sep 15, 2017 at 20:09
  • 1
    This affects Neovim too. With a regular SSH connection if you do :echo has('clipboard') you get 0. However once you connect with ssh -Y then :echo has('clipboard') gives you 1. I got the `has('clipboard') check from here: stackoverflow.com/a/11489440/327074
    – icc97
    Dec 14, 2020 at 9:13
  • 1
    Could you extend the which is somewhat too restrictive bit? What's the problem with just -X/untrusted mode? Seems to work fine.
    – Pablo A
    Oct 14, 2021 at 4:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .