2

Is there a way to enable xclip/xsel on a headless SSH server? I'm working with a machine that formerly ran Ubuntu 14.04 desktop, and has been migrated to Ubuntu 16.04 server. I have various vim and tmux configurations to increase productivity when I login to the server via ssh. However, now that it's headless and running a server OS, a lot of my clipboard functionality is broken:

  • "+y no longer works in vim (which we recompiled with xterm_clipboard support), so I've lost a convenient way to copy vim buffers between tmux windows on the remote machine.
  • tmux copy/paste works fine, which is odd, given that my "yank" command is:
    • bind -t vi-copy 'y' copy-pipe "xclip -sel clip -i" (this worked even with xclip not even installed; guess it fell back to default behavior).
  • cygwin no longer seems to acquire a copy of clipboard data when x11forwarding is enabled via ssh -X hostname.

Is there a way to get this working from a "cygwin on windows" to "ubuntu 16.04.3 headless server" setup? I'd even install xorg if necessary, if it just sat quietly in the background and allowed the clipboard to work again.

phd
  • 82,685
  • 13
  • 120
  • 165
Cloud
  • 18,753
  • 15
  • 79
  • 153
  • Related Posts: [How can I copy text to the system clipboard from Vim?](https://vi.stackexchange.com/q/84/778) & [How can I copy over an ssh session without +clipboard?](https://vi.stackexchange.com/q/8354/778). Related article using `netcat`: [Exposing your clipboard over SSH](https://gist.github.com/dergachev/8259104) and [what I use](https://gist.github.com/PeterRincker/8fab6296b6905793e284e84aba7041bc) with this technique. – Peter Rincker Jan 18 '18 at 15:40

1 Answers1

2

On the server, install the vim-gtk package. It comes with the necessary dependencies for clipboard to work through X Forwarding.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • Is this an option I could just pass to vim and recompile? Or does vim-gtk come with some additional libraries/tools/features? I'd like to use my local build of vim. – Cloud Jan 18 '18 at 16:58
  • You need Vim compiled with clipboard support on both ends to benefit from X forwarding. – romainl Jan 18 '18 at 17:12
  • I've just tried rebuilding VIM like this, ssh'ing into the headless server, starting tmux, then opening vim in multiple tmux windows: none of the vim instances can paste to each other using `"+y`/`"+p`: they can only share via the tmux paste buffers. Each vim instance can copy/paste to itself using that buffer though. – Cloud Jan 18 '18 at 17:23
  • Was forgetting to use "ssh -Y" afterwards. – Cloud Jan 18 '18 at 17:41