Ever tried copying code from SSH conn and ended up doing a “finger workout” in your keyboard? Me too
Recently I’ve given a crack into this “run agent in another machine thing”. At least for me, RAM is very expensive right now and my Thinkpad is strugling to keep up with it’s mere 16 GB.
But hey, I do have an older laptop with another 16 GB. It’s DDR4, but still works. Arch installed, ssh configured… And having to “Ctrl + Alt + Shift + select” to copy every time.
Not ideal, but worry not. Let’s see how a shared clipboard over SSH in Wayland.
NOTE: I personally use wayland and sway. But this should work across all waylandroots based environments.
Packages needed
This is a cortersy of this incredible package called Waypipe.
It was packages for ubuntu, arch and I believe most maintream distributions. If not, you can compile yourself, just follow the README of the project and you’re good to go.
| |
NOTE: It’s imperative for you to install in both the HOST (ssh server) and the client (your machine).
Setting everything up
Now you only need to connect to your server, using their wrapper.
| |
If it’s a headless server (no GUI), you might get a vulkan error. This happens because it tries to access the GPU from your server, and if you don’t have the drivers, no bueno.
To prevent that, you can use the flag no-gpu and you’re good to go.
| |
It’s too hard to type it EVERY time
Yeah, fully agree. Let’s fix that. In my case, I’ve just setup an alias in my ~/.bashrc.
| |
DONE! Whenever want to connect with the [c]lipboard enabled, I just type sshc user@host and it will work flawlessly.
Tmux idiosyncrasies
Tmux has it’s own display and socket thing going on and it often conflict with waypipe. But the fix is easy enough: just add some config to your .tmux.conf.
set -g update-environment "DISPLAY WAYLAND_DISPLAY XDG_RUNTIME_DIR SSH_AUTH_SOCK"
set-hook -g client-attached 'run-shell "tmux setenv -g WAYLAND_DISPLAY #{WAYLAND_DISPLAY}"'
Reload with source ~/.tmux.conf (or close all your tmuxes) and you can now access the clipboard, even
from the remote machine. Even from opencode auto select/copy.