Skip to content

Instantly share code, notes, and snippets.

@robotanarchy
Last active August 29, 2015 14:21
Show Gist options
  • Save robotanarchy/5d2cef8ccf5c80115119 to your computer and use it in GitHub Desktop.
Save robotanarchy/5d2cef8ccf5c80115119 to your computer and use it in GitHub Desktop.
Synergy as x2x over SSH replacement
#!/bin/sh
#
# Author: robotanarchy
# Source: http://git.io/synergy-over-ssh
# License: Public Domain
#
# This script is an alterantive to x2x over ssh, for connecting two
# machines with synergy over SSH and sharing mouse and keyboard from
# the local machine to the remote machine.
#
#
# -------------- Mouse, Keyboard ---------------------
# | LOCAL | ----------------> | REMOTE SSH-Server |
# -------------- | with display |
# | eg. Laptop | |___________________|
# '''''''''''''' ______|______
#
# In other words the "local" keyboard and mouse will be able to control
# the remote display.
#
# When you're done, press CTRL+C in the open terminal to close the
# connection.
# make sure this port is available on both machines
port=24800
local_display=:0
remote_display=:0
# with a different user: "user@hostname"
# with a different port: -p 1337 user@hostname
remote_hostname=changeme
# start server locally, localhost only
# (foreground + &, so it shows important messages)
export DISPLAY=${local_display}
synergys -d WARNING -a "localhost:$port" -f &
# remote: build a reverse ssh tunnel, and connect to the server
ssh -R $port:localhost:$port ${remote_hostname} "DISPLAY=:${remote_display} synergyc --no-restart -d WARNING -f localhost:${port}"
# cleanup
killall synergys
@robotanarchy
Copy link
Author

Sample config (must be installed on the local machine as /etc/synergy.conf):

# Sample config for http://git.io/synergy-over-ssh
# replace remote and local with the hostnames!
# More config options: http://synergy-project.org/wiki/Text_Config

section: screens
        remote:
        local:
end

section: links
        remote:
                down = local
        local:
                up = remote
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment