Skip to content

Instantly share code, notes, and snippets.

@chrisdiana
Last active February 1, 2024 06:11
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrisdiana/e2e471f4451f5fa16c3b9ef28037c57a to your computer and use it in GitHub Desktop.
Save chrisdiana/e2e471f4451f5fa16c3b9ef28037c57a to your computer and use it in GitHub Desktop.
Getting mosh server running on macOS Catalina

Running into this error message when trying to run a mosh server on macOS Catalina? The steps below should solve the problem which is most likely either a $PATH and/or firewall issues.

command not found: mosh-server
Connection to X.X.X.X closed.
/usr/local/bin/mosh: Did not find mosh server startup message. (Have you installed mosh on your server?)

1. Install Mosh

$ brew install mosh

2. Update path to include mosh-server

zsh

$ echo "export PATH=$PATH:/usr/local/bin" >> ~/.zshenv

bash

$ echo "export PATH=$PATH:/usr/local/bin" >> ~/.bashrc

3. Update the firewall

# Turn the firewall off
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off

# Enable the firewall rules (make sure you are using your actual path)
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /usr/local/bin/mosh-server

# Unblock the app
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp /usr/local/bin/mosh-server

# Turn the firewall back on
$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on

4. Now try connecting using the mosh client

$ mosh user@X.X.X.X
@dberkholz
Copy link

Just got mosh-server running on a Mac via SSH using this little snippet. Thanks!

@Boggnogg
Copy link

Just an addition if the above does not work (had the same issue while trying to connect from iPad to iMac (Ventura)):

If you installed mosh via brew, the binaries are usually located in '/usr/local/Cellar/mosh/...' and only links created in '/usr/local/bin'. For the macOS Firewall to allow connections, you have to give permissions to the binary and not the symlink. So just add '/usr/local/Cellar/mosh/.../mosh-server' for incoming connections. - Worked for me.

@mipmip
Copy link

mipmip commented Aug 31, 2023

@Boggnogg this last part made it working. Thanks!

@penso
Copy link

penso commented Sep 17, 2023

Just an addition if the above does not work (had the same issue while trying to connect from iPad to iMac (Ventura)):

If you installed mosh via brew, the binaries are usually located in '/usr/local/Cellar/mosh/...' and only links created in '/usr/local/bin'. For the macOS Firewall to allow connections, you have to give permissions to the binary and not the symlink. So just add '/usr/local/Cellar/mosh/.../mosh-server' for incoming connections. - Worked for me.

That fixed it here too. Thanks!

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