Sunan an-Nasa'i #690 · The Book of the Masjids

Sunan an-Nasa'iIt was narrated that Ibrahim said
Sunan an-Nasa'i · Book 8 · The Book of the Masjids
Sunan an-Nasa'i · كتاب 8 · كتاب المساجد
"I used to recite Qur'an to my father on the road, and if I recited a verse in which prostration was required, he would prostrate. I said: 'O my father, do you prostrate on the street?' He said: 'I heard Abu Dharr say: "I asked the Messenger of Allah (ﷺ): 'Which Masjid was built first?' He said: 'Al-Masjid Al-Haram.' [1] I said: 'Then which?' He said: 'Al-Masjid Al-Aqsa.' [2] I said: 'How long was there between them?' He said: 'Forty years. And the earth is a Masjid (or a place of prostration) for you, so wherever you are when the time for prayer comes, pray.'" [1] In Makkah. [2] "Furthest Masjid", meaning the Masjid in Jerulsalem
أَخْبَرَنَا عَلِيُّ بْنُ حُجْرٍ، قَالَ حَدَّثَنَا عَلِيُّ بْنُ مُسْهِرٍ، عَنِ الأَعْمَشِ، عَنْ إِبْرَاهِيمَ، قَالَ كُنْتُ أَقْرَأُ عَلَى أَبِي الْقُرْآنَ فِي السِّكَّةِ فَإِذَا قَرَأْتُ السَّجْدَةَ سَجَدَ فَقُلْتُ يَا أَبَتِ أَتَسْجُدُ فِي الطَّرِيقِ فَقَالَ إِنِّي سَمِعْتُ أَبَا ذَرٍّ يَقُولُ سَأَلْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم أَىُّ مَسْجِدٍ وُضِعَ أَوَّلاً قَالَ ‏
"‏ الْمَسْجِدُ الْحَرَامُ ‏"‏ ‏.‏ قُلْتُ ثُمَّ أَىُّ قَالَ ‏"‏ الْمَسْجِدُ الأَقْصَى ‏"‏ ‏.‏ قُلْتُ وَكَمْ بَيْنَهُمَا قَالَ ‏"‏ أَرْبَعُونَ عَامًا وَالأَرْضُ لَكَ مَسْجِدٌ فَحَيْثُمَا أَدْرَكْتَ الصَّلاَةَ فَصَلِّ ‏"‏ ‏.‏
Reference : Sunan an-Nasa'i 690In-book reference : Book 8, Hadith 3