“My roommate said, ‘Well, the good Lord also wants the rest of us to be healthy, too,’” he said.

While much of New York City is staying inside, a crisis has taken hold among a population for whom social distancing is nearly impossible: the more than 17,000 men and women, many of them already in poor health, who sleep in roughly 100 group or “congregate” shelters for single adults. Most live in dormitories that are fertile fields for the virus, with beds close enough for people sleeping in them to hold hands.

And rather than keeping people away from shelters, the virus has driven them in.

Some inmates released from Rikers Island to control the outbreak in the jail have wound up in shelters. And with the outdoor safety net falling apart — few pedestrians to beg for change; public bathrooms shut; many soup kitchens closed for lack of food and volunteers — the nightly shelter population has consistently reached levels seen only a few times in the last decade, and usually only on the most frigid nights of winter.

“When all of those systems simultaneously break down, you’re going to get this influx into congregate situations,” said Joshua Goldfein, a staff attorney at the Legal Aid Society. “It’s a time bomb.”

Officially as of Sunday, 23 shelter residents have died in hospitals, among them 14 men and two women from assessment centers and shelters for single adults where multiple, unrelated people share rooms, according to the Department of Homeless Services.

And 371 people from shelters had tested positive for the virus, about 80 percent of them from the single-adult facilities, though those adults represent less than a quarter of the homeless population. The rest are mostly families who often stay in studio-like units by themselves.