The American-English phrase to ride shotgun means, literally, to travel as an armed guard next to the driver of a vehicle.
These are, in chronological order, the earliest occurrences of this phrase that I have found:
1 & 2-: From two books by the U.S. novelist and short-story writer Alfred Henry Lewis (1855-1914):
1-: From the historical novel The Sunset Trail (New York: A. S. Barnes & Co., 1905):
Wyatt and Morgan Earp 1 were in the service of the Express Company. They went often as guards—“riding shotgun,” it was called—when the stage bore unusual treasure.
1 Wyatt Earp (1848-1929) and Morgan Earp (1851-1882), his brother, were lawmen.
2-: From Old Monte, Official Drunkard, published in the collection of stories titled Faro Nell and Her Friends: Wolfville Stories (New York: G. W. Dillingham Company, 1913)—Monte is a stage driver:
“That lack of war instinct in Monte ain’t no speecific drawback. Him drivin’ stage that a-way, he ain’t expected none to fight. The hold-ups onderstands it, the company onderstands it, everybody onderstands it. It’s the law of the trail. That’s why, when the stage is stopped, the driver’s never downed. Which if thar’s money aboard, an’ the express outfit wants it defended, they slams on some sport to ride shotgun that trip.”
3-: From the biography of Wyatt Earp, by Fred E. Sutton, published in The Dallas Morning News (Dallas, Texas) of Sunday 17th February 1929:
Wyatt was at one time half owner in the Oriental gambling house that had been badly shot up many times while it was under the management of his partner, so he resolved to take over the management for a time and see what could be done to stop this indiscriminate shooting. […]
Previous to this he had been riding “shotgun” for the Wells-Fargo 2 people, but when he took over the management of the Oriental he resigned and had his brother Morgan appointed to his place.
2 Wells, Fargo & Co. was a U.S. transportation company founded in 1852 by the businessmen Henry Wells (1805-1878), William Fargo (1818-1881) and others.
In extended use, the phrase to ride shotgun has come to mean to accompany, to escort, especially in to ride shotgun on somebody. These are the earliest occurrences of that extended use that I have found:
1-: From the caption to the following photograph, published in The Cincinnati Enquirer (Cincinnati, Ohio) of Monday 8th November 1948:
CUMMINSVILLE FOLK AMUSED: Norb (I Lost On Dewey) Ankenbauer paid off for backing the losing presidential candidate by pushing William Abbott in a wheel barrow from Colerain and Virginia Aves. to the Mt. Airy Forest main entrance yesterday, more to the amusement of their Cumminsville neighbors. Ed Mohr rides “shotgun” to see that Ankenbauer carries out the bet.
2-: From Dog-gonnest liar tells horrible tale, published in the Daily News (Los Angeles, California) of Tuesday 27th December 1949:
Harry Oliver is a liar.
And you don’t have to smile when you call him one.
The last time he told the truth was 30 years ago in a saloon in the old mining town of Julian.
He was bellying up to the bar for a Rock Hound Special (a shot of tequila with a whisky chaser) when a dance hall gal came swanking through the swinging doors.
Harry had been prospecting out in the Borego badlands with nothing but mules to keep him company, so he told the lady she was the prettiest thing he’d seen since a picture postcard of Lillian Russell.
“And so she was,” remembers Harry, “so she was.”
Next thing he knew she was dragging him down the street to the preacher’s, with all the respectable men in town riding shotgun behind them.
Harry made his escape through a window just in the nick of time, but since then he hasn’t told the truth to man, woman or mule.
Figuratively, the phrase to ride shotgun has come to also mean to assist, to protect, especially in to ride shotgun on somebody. These are the earliest occurrences of that figurative use that I have found:
1-: From an Associated-Press story, published in several newspapers on Wednesday 7th December 1949—for example in The Kansas City Star (Kansas City, Missouri):
Los Angeles, Dec. 7 (AP)—The shah of Iran prepared to leave town today, evidently unperturbed over a wealthy sports patron’s effort to crash the royal party by using two top athletes to run his interference.
Bob Mathias, Olympic decathlon champ, and Glenn Davis, onetime All-American halfback at Army, were to have met his imperial majesty yesterday. But the man who promoted the venture forgot to let the shah in on it.
There were no ill feelings, only a look of disappointment on the features of Russell E. Baum, a Wynnewood, Pa, manfacturer [sic] and party thrower.
A spokesman for the State department, which is more or less riding shotgun on the shah’s tour of this country, hastened to explain that the Iranian ruler wasn’t trying to snub the boys.
The visit probably could have been arranged, the spokesman said, had Baum gone through proper channels.
2-: From the column The Yale Bowl, by Harvey W. Yale, Star Sports Editor, published in the Valley Morning Star (Harlingen, Texas) of Friday 16th February 1951:
Howard Capps, the PGA [Professional Golfers’ Association] tournament supervisor, hard pressed as he is with golf, sponsors and the United States State Department, seemingly has taken over a new duty, riding shotgun on interviews being conducted by the press.
He claimed it was an accident Thursday when he was discovered sitting in on Harold Ratliff’s interview of Marty Furgol who had just finished with a well-stroked 65.
Accidental or not, it just might not be a bad idea at that, sitting in on these interviews, that is. […]
Having seen a pro or two quoted, it becomes obvious that the touring golfers need an interperter [sic] or press lawyer to lend a helping hand over an exposed situation.
[…] Who, except a hard-shelled sports writer, a veteran at the game, could better serve as teacher. Conduct a permanent clinic in press relations for PGA tournament players with some old scribe old enough to be level-headed—not flat-headed—but not so old as to be reactionary, who would give the pros the straight dope on what to say and how it will sound to other sports writers who must take such quotes and make a readable story out of it.
3-: From an interview of Seymour Heller (1914-2001), who was the personal manager for the U.S. pianist and entertainer Władziu Valentino Liberace (1919-87)—interview by John Keasler, published in the St. Louis Post-Dispatch (St. Louis, Missouri) of Friday 18th November 1955:
We had a talk the other day with a pleasant gentleman named Seymour Heller who rides shotgun on a phenomenon named Liberace, and that is indeed quite a job.