Skip to content

Instantly share code, notes, and snippets.

@WisdomCode
Created June 5, 2019 12:14
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save WisdomCode/f7478d0ac9969ebfb3615204b3dc956a to your computer and use it in GitHub Desktop.
Save WisdomCode/f7478d0ac9969ebfb3615204b3dc956a to your computer and use it in GitHub Desktop.
Moonlight Game Streaming via SSH
#!/bin/bash
#Enables Playing on a moonlight server via an ssh tunnel. This is useful on restricted networks, as only the ssh port is needed.
#Needs the complimentary script, redirectudp, running on the ssh server to function.
#needs a private key for the ssh server
#sudo apt install ssh socat snap
#snap install moonlight
#IP of the gaming rig on the local network
gip=IP
#User and Address of the SSH server (sharing local network with the gaming rig
sshuser=USER
sip=DOMAIN
#Program to start with moonlight
app=Desktop
ssh \
-L 47984:$gip:47984 \
-L 47989:$gip:47989 \
-L 48010:$gip:48010 \
-L 48998:localhost:48998 \
-L 48999:localhost:48999 \
-L 49000:localhost:49000 \
-L 49002:localhost:49002 \
-L 49010:localhost:49010 \
-N $sshuser@$sip &
socat -T15 udp4-recvfrom:47998,reuseaddr,fork tcp:localhost:48998 &
socat -T15 udp4-recvfrom:47999,reuseaddr,fork tcp:localhost:48999 &
socat -T15 udp4-recvfrom:48000,reuseaddr,fork tcp:localhost:49000 &
socat -T15 udp4-recvfrom:48002,reuseaddr,fork tcp:localhost:49002 &
socat -T15 udp4-recvfrom:48010,reuseaddr,fork tcp:localhost:49010 &
moonlight stream localhost $app
kill $(lsof -t -i:49000)
#!/bin/bash
#complementary script for the moonlightssh script. Run it on the ssh server.
#sudo apt install socat
#IP of the Gaming rig
sip=IP
socat tcp4-listen:48998,reuseaddr,fork udp:$sip:47998 &
socat tcp4-listen:48999,reuseaddr,fork udp:$sip:47999 &
socat tcp4-listen:49000,reuseaddr,fork udp:$sip:48000 &
socat tcp4-listen:49002,reuseaddr,fork udp:$sip:48002 &
socat tcp4-listen:49010,reuseaddr,fork udp:$sip:48010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment