MacOS

SSH

SSH tips and tricks for macOS

Priority Login Under Heavy Load

When a server is under heavy load, new SSH connections may be slow or time out. You can use nice to give your shell higher CPU priority immediately upon login:

Terminal
ssh -o ConnectTimeout=1 -o ConnectionAttempts=1 user@host "nice -n -20 bash"

What This Does

  • ConnectTimeout=1 — Fail fast if the server doesn't respond within 1 second
  • ConnectionAttempts=1 — Only try once (don't waste time retrying)
  • nice -n -20 — Start your shell with the highest CPU scheduling priority
  • bash — Launch an interactive shell with that priority

When to Use It

  • Server is under heavy CPU load and normal SSH feels unresponsive
  • You need to get in quickly to diagnose or fix an issue
  • Regular SSH connections are timing out or extremely slow
Running nice -n -20 requires root privileges. If you're logging in as a non-root user, use sudo nice -n -20 bash instead, or configure your user with the appropriate permissions.