Ali al-Azdi reported that Ibn Umar taught him that whenever the Messenger of Allah ﷺ mounted his camel to set out on a journey, he would say "Allahu Akbar" three times, then recite, "Glory be to Him who has subjected this to us, for we could never have accomplished it ourselves, and indeed to our Lord we shall return" [Zukhruf 43:13–14].Then he would say, "O Allah, I ask You on this journey of ours for righteousness, piety, and deeds that please You. O Allah, make this journey easy for us and shorten its distance for us. O Allah, You are the Companion on the journey and the Guardian of the family and property left behind."When he returned, he would say the same words and add to them, "Returning, repenting, worshipping, and praising our Lord."Whenever the Prophet ﷺ and his armies climbed a mountain pass, they would proclaim "Allahu Akbar," and when they descended, they would say "Subhan Allah." The prayer was structured upon this pattern.
حدثنا الحسن بن علي حدثنا عبد الرزاق أخبرنا ابن جريج
أن عليا الأزدي أخبره أن ابن عمر علمه أن رسول الله ﷺ كان إذا استوى على بعيره خارجا إلى سفر كبر ثلاثا ثم قال {سبحان الذي سخر لنا هذا وما كنا له مقرنين وإنا إلى ربنا لمنقلبون} اللهم إني أسألك في سفرنا هذا البر والتقوى ومن العمل ما ترضى اللهم هون علينا سفرنا هذا اللهم اطو لنا البعد اللهم أنت الصاحب في السفر والخليفة في الأهل والمال وإذا رجع قالهن وزاد فيهن آيبون تائبون عابدون لربنا حامدون وكان النبي ﷺ وجيوشه إذا علوا الثنايا كبروا وإذا هبطوا سبحوا فوضعت الصلاة على ذلك
[Sahih] Recorded by Muslim, Hajj, chapter on the recommendation of remembrance when mounting one's riding animal setting out on a journey, etc., hadith no. 1342, from the hadith of Ibn Jurayj through this route, without the phrase, "The Prophet ﷺ and his armies, whenever they climbed a hill in Hajj or elsewhere..." etc.