Why SSH keeps spawning new processes on every connect
Every time I run ssh host, the client forks a new process that talks to the remote sshd.
On the server side, sshd spawns a child for each accepted connection.
The model is simple and works fine for a handful of sessions, but it starts to feel like a drain when you:
- run a script that opens dozens of SSH connections in a row,
- use CI/CD pipelines that hit a remote host repeatedly, or
- have a home‑lab with many small services that need quick SSH access.
Each fork eats a few kilobytes of RAM and a handful of file descriptors.
If you hit the per‑user process limit (ulimit -u) or the system’s max_user_processes, you’ll see “Too many users” or “Connection refused” errors.
Even on a modest machine, the cumulative CPU cost of negotiating the SSH handshake over and over can add up.