(*) This was 2000 years before time zones became a thing and local solar times were disengaged from the wallclock time. Not that ancient Greeks had wallclocks.
The key, really, was to be able to pick 2 locations on the same longitude and to have enough math/trigo to perform the calculation.
The angle between the sun and the zenith at local solar noon will be the same everywhere at a given latitude so that part doesn't care if the cities are on the same longitude..
You do need to know the north/south distance between the latitudes of the two cities, and picking two cities on the same longitude makes that easier to measure: just go straight from one to the other and note how far you traveled.
If the longitude was substantially different you'd have to use spherical trigonometry to figure out the north/south distance from the distance and bearing of the straight route between the cities, and for that you need to know the size of the sphere you are on.
Instead you'd have to do something like travel north from the southern city until you are at the same latitude as the other city (probably determined by observing the altitude of the North star), note how far you've traveled, then travel east or west along a line of constant latitude to try to reach the other city. If you miss the other city because you didn't get the latitude quite right, you'd have to move north or south, updating your north/south distance estimate, and try again, repeating until you actually hit the other city.
Egypt had a solar based-calendar, so (to a decent approximation) on every named date the sun would be in the same place in the sky.
So all that would be needed was for it be known that the sun shined straight down the well on (for instance) the 14th day of the 2nd Month of Growth (I had to look up the Egyptian calendar to get that date!), and Eratosthenes just needed to measure on that date.
You and I could sit at Christmas dinner, and conspire to measure the shadow of a 1metre pole at solar noon on Easter Sunday, at our respective locations.
We could then compare those measurements when we meet next Christmas.