I usually focus on short term goals, the next route sheet instruction, the top of a hill, or some other tangible mental tick. Scenery does help, as does people watching, just seeing everybody go about their business.
This doesn't work so well at the most difficult points - where it is dark and/or wet so you can't see the hills, people, or anything else. Then the cycle computer becomes my motivation. It's set to km but I then compute the distance to the next control / finish in both miles and km, which gives me lots of little "goals" - it's only 20km to the control, then, not too much later it will be only 11miles, etc. The cognitive requirements of multiplying or dividing by 1.6 are sufficient to produce some distraction, until hopefully there is some moonlit scenery or a descent, or something else to distract the mind.
Having done some long distance running, I think it is more painful that long distance cycling (unless you develop an injury), and so possibly the distraction techniques can be a little more gentle.