0×1337.de_blog about security, open source, music and revolution.

July 23, 2009

Secure Synergy

Filed under: cli, linux, security — Tags: , , , , , , , — flyc0r @ 3:49 pm

I have been using synergy for a long time now. The only ugly thing about it: it doesn’t encrypt. That’s where ssh comes in. I wrote this handy script a while ago to start ssh tunneled synergy on a client machine:

 #!/bin/sh
port=24800
host=$1

echo -n killing existing synergyc...
killall -9 synergyc
echo done

echo -n killig existing ssh tunnels...
pids=$(ps x |grep ssh|grep $port|grep $host|cut -d' ' -f1)
for i in $pids
	do
		echo -n "killing $i..."
		kill -9 $i;
		echo done
	done

echo -n "Trying to ping $host"
if ping -c1 $1>/dev/null;
 then
	echo done
	echo -n starting ssh tunnel...
	ssh -f -N -L 127.0.0.1:$port:$1:$port $host
	echo done
	echo -n starting synergyc...
	sleep 1
	synergyc 127.0.0.1
	echo done
  else
	echo "failed."
fi
echo done

Powered by WordPress