The lead character ends up (unwillingly) in the space of the ally behind
As usual in 5e D&D the RAW are silent here. The closest we get is:
MOVING AROUND OTHER CREATURES: You can move through a non hostile creature’s space. (...) Whether a creature is a friend or an enemy, you can’t willingly end your move in its space. (PHB 191, my emphasis)
As the character behind is an ally, the lead character can enter his space. He cannot stay there willingly, but as he was shoved it was unwilling, so that's OK.
This is not technically RAW as the character is being shoved, not taking his move, but this situation does at least make sense of the "willingly" in the RAW. Also it's not a big stretch of the RAW. The shoved character is moving in the common sense even if not taking his Move.
What happens to the ally is really not covered by the RAW
Here the RAW are totally silent so DM's discretion must prevail. My subjective suggestion would be for the shoved-onto character to make a Strength (Athletics) roll to catch the shoved character, or a Dexterity (Acrobatics) roll to get out of the way.