Skip to content

Instantly share code, notes, and snippets.

@trodemaster
Last active June 19, 2020 06:48
Show Gist options
  • Save trodemaster/a9c4ba2075c307eb2492e4082b2888b8 to your computer and use it in GitHub Desktop.
Save trodemaster/a9c4ba2075c307eb2492e4082b2888b8 to your computer and use it in GitHub Desktop.
# Setup code-server on macos 10.15.x
https://github.com/cdr/code-server
Download a release binary for macOS
wget https://github.com/cdr/code-server/releases/download/v3.4.1/code-server-3.4.1-macos-amd64.tar.gz
# Unzip and put it someplace
tar -zxf ~/Downloads/code-server-3.4.1-macos-amd64.tar.gz -C ~/
# remove quarantine
sudo xattr -dr com.apple.quarantine ~/code-server-3.4.1-macos-amd64
# create totally insecure self signed cert
openssl req -x509 -newkey rsa:4096 -keyout ~/certs/hostname.key -out ~/certs/hostname.crt -days 9999 -nodes
# install cert to keychain and trust it so it will load in chrome on the server mac
sudo security add-trusted-cert -d -r trustRoot -k ~/Library/Keychains/login.keychain-db ~/certs/hostname.crt
# hackup this launchd plist to taste and install at ~/Library/LaunchDaemons/code-server.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>code-server</string>
<key>ProgramArguments</key>
<array>
<string>/Users/username/code-server/code-server-3.4.1-macos-amd64/bin/code-server</string>
<string>--disable-updates</string>
<string>--bind-addr</string>
<string>hostname.domain.com:8080</string>
<string>--cert</string>
<string>/Users/username/certs/hostname.domain.com.crt</string>
<string>--cert-key</string>
<string>/Users/username/certs/hostname.domain.com.key</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/bin:/opt/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
<key>PASSWORD</key>
<string>mywebpassword</string>
</dict>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/Users/username/Library/Logs/code-server.log</string>
<key>StandardErrorPath</key>
<string>/Users/username/Library/Logs/code-server.log</string>
</dict>
</plist>
# run this command to start the server
launchctl load -w ~/Library/LaunchDaemons/code-server.plist
# Check the logs for any errors
cat ~/Libraary/Logs/code-server.log
# restarting the server with these two commands
launchctl unload ~/Library/LaunchDaemons/code-server.plist
launchctl load ~/Library/LaunchDaemons/code-server.plist
/opt/local/lib/libicui18n.dylib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment