Copy input to clipboard over SSH?

If you run ssh with X forwarding, this is transparent: remote commands (including xclip) have access to your X server (including its keyboard). Make sure you have ForwardX11 yes in your ~/.ssh/config and X11Forwarding yes in the server sshd_config (depending on your distributions, these options may be on or off by default).

<myconffile.conf sed {...} | xclip -i

There are other ways of working on remote files that may be more convenient, for example mounting remote directories on your local machine with SSHfs, or opening remote files in Emacs with Tramp. If you have ssh and FUSE set up and SSHfs installed, SSHfs is as easy as mkdir ~/net/myserver; sshfs myserver:/ ~/net/myserver. If you have ssh set up and Emacs installed, Tramp is as easy as opening /myserver:/path/to/file.


You don't need anything special; since xclip works over stdin, just

ssh remotehost xclip < myconf.conf

Why would it need to be modified with sed? ssh is transparent to data when not used as a terminal, and is commonly used in pipelines such as

tar cfz - somedir | ssh remotehost 'cd destdir; tar xfz -'`

Here's how you would do it on OSX from your local machine

ssh remotehost.com "<some/file.txt" | pbcopy