As someone else pointed out in a sub-comment, ssh user@host 'command' | pbcopy; seems a lot simpler. No open ports, no firewall config... no setup at all. It doesn't give you the access to the pasteboard in your current session, but Command+C has you covered.<p>Seems like overkill.
I did something similar for the "open" command, "ropen": <a href="https://github.com/tlrobinson/ropen" rel="nofollow">https://github.com/tlrobinson/ropen</a> You can open both files and directories. It uses sshfs with simple PHP script to coordinate. I used it for a couple weeks then forgot about it.<p>Then I did this one using Dropbox, but it only works if you have Dropbox installed on both machines:<p><pre><code> alias dbcopy="cat > ~/Dropbox/.dbpasteboard"
alias dbpaste="cat ~/Dropbox/.dbpasteboard"
</code></pre>
I think there's probably a better solution than all of these.
While on this general subject, here's what I use to do the equivalent X copy and paste thing on Linux:<p><pre><code> # 'pbcopy'
xsel -b -i
# 'pbpaste'
xsel -b -o</code></pre>
For windows users this project
<a href="http://unxutils.sourceforge.net/" rel="nofollow">http://unxutils.sourceforge.net/</a><p>has 'pclip' and 'gclip' which do the same thing as 'pbcopy' and 'pbpaste'.<p>I have been using this technique for years (without the remote stuff described in the article).
Can't this be achieved just using ssh instead of setting up a process that listens to the network?<p>from remote machine:<p><pre><code> ssh me@macbook pbcopy < foo.txt</code></pre>