Hermit crabs mate when the male hermit crab places his reproductive organ, the spermatophore, into the female hermit crab's reproductive openings, the gonopores. It can be somewhat difficult to determine the sex of hermit crabs.
The male's spermatophore is located near the fifth pair of legs, and the female's gonopores are located on the first segment of the back pair of walking legs. The male hermit crab initiates mating by tapping on and rocking the female crab's shell to encourage her to come out of the shell far enough for mating to take place. They mate in a position where the female's gonopores align with the male's fifth set of legs.