Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@boichee
Last active August 1, 2019 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boichee/34739c360bc2aa3b97f81adb51ec59de to your computer and use it in GitHub Desktop.
Save boichee/34739c360bc2aa3b97f81adb51ec59de to your computer and use it in GitHub Desktop.
A shell function for macOS that allows mosh-server to send/receive traffic without having to deactivate the firewall
# Mosh Server on macOS Mojave is blocked by the packet filter.
# Modifying the pf.conf for pfctl is not enough to make it work.
# The following function does, however, seem to allow the necessary
# traffic to pass through the firewall
fix_mosh_server() {  ✔  10037  13:10:10
local fw='/usr/libexec/ApplicationFirewall/socketfilterfw'
local mosh_sym="$(which mosh-server)"
local mosh_abs="$(greadlink -f $mosh_sym)"
sudo "$fw" --setglobalstate off
sudo "$fw" --add "$mosh_sym"
sudo "$fw" --unblockapp "$mosh_sym"
sudo "$fw" --add "$mosh_abs"
sudo "$fw" --unblockapp "$mosh_abs"
sudo "$fw" --setglobalstate on
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment