Random errors on macOS 26.6: unable to connect to Podman socket: failed to connect: ssh: handshake failed: EOF
I'm not quite sure if this started only with macOS 26.6 or with the latest podman version (6.0.2), but when using podman-compose build or podman-compose up on our docker-compose.yaml with 42 services (many of which require building a custom image), I randomly get one or multiple lines with:
Error: unable to connect to Podman socket: failed to connect: ssh: handshake failed: EOF
Repeating the command sometimes prints more or less or no such errors. My podman machine is based on applehv:
podman machine init --disk-size 100 --memory 32768 --cpus 5 --swap 32768 --rootful --now
So the resources should be sufficient. Maybe there are just too many parallel connections at once such that some of them get rejected? Could this be handled more gracefully?
ASSIGN
When podman-compose runs 42 services in parallel, each podman process opens its own SSH connection to the VM, overwhelming the guest's OpenSSH MaxStartups default (10 concurrent unauthenticated connections before random drops begin), causing sshd to reject handshakes with EOF. Podman never configures a higher MaxStartups in the guest VM's sshd, and has no SSH-dial retry logic to recover from transient drops.
I am not sure if this is a Compose problem or podman.
Maybe it's both. Compose is opening too many connections/builds in parallel and probably overwhelming the little podman VM, but that could be configurable or better yet based on the number of CPUs and amount of RAM assigned to the VM. The podman VM should still have a higher limit by default, probably also based on CPU and RAM. And podman should probably also have retry logic for rejected connections.
IMO, this is caused by MaxStartups (see this Stack Overflow thread), and changing that setting isn't a good idea. It is a safety measure.
Every call creates its own process that opens an SSH connection. At this scale, it's practically a DDoS attack on SSH. Retry logic would help, but it probably won't scale if we reach a huge number of services. SSH multiplexing between processes might be a better option, though I haven't looked into how Compose calls Podman yet.
The latest podman machine VMs come with a higher MaxStartups (/etc/ssh/sshd_config.d/99-podman-sshd.conf), but this didn't help unfortunately. Still getting lots of "handshake failed: EOF" errors.
I've found a workaround (which requires installing podman-compose within the podman machine):
podman machine ssh -- "cd '$(pwd)' && podman compose up"
This way just one SSH connection is opened and podman works reliably within the VM. Still, it would be great to solve this problem for real, so using podman from the host is also possible.