Ubayy ibn Ka’b reported: There was a man who lived the furthest from the mosque, as far as I know. He never missed a congregational prayer. It was said to him, “If you buy a donkey, you can ride it during the dark nights and hot days.” The man said, “I do not like for my house to be so close to the mosque. I want my walking towards the mosque, as well as returning to my home and family, to be recorded as good deeds for me.” The Messenger of Allah, peace and blessings be upon him, said, “Allah has gathered all of that for you.”
Source: Ṣaḥīḥ Muslim 663
Grade: Sahih (authentic) according to Muslim
عَنْ أُبَيِّ بْنِ كَعْبٍ قَالَ كَانَ رَجُلٌ لَا أَعْلَمُ رَجُلًا أَبْعَدَ مِنَ الْمَسْجِدِ مِنْهُ وَكَانَ لَا تُخْطِئُهُ صَلَاةٌ قَالَ فَقِيلَ لَهُ أَوْ قُلْتُ لَهُ لَوِ اشْتَرَيْتَ حِمَارًا تَرْكَبُهُ فِي الظَّلْمَاءِ وَفِي الرَّمْضَاءِ قَالَ مَا يَسُرُّنِي أَنَّ مَنْزِلِي إِلَى جَنْبِ الْمَسْجِدِ إِنِّي أُرِيدُ أَنْ يُكْتَبَ لِي مَمْشَايَ إِلَى الْمَسْجِدِ وَرُجُوعِي إِذَا رَجَعْتُ إِلَى أَهْلِي فَقَالَ رَسُولُ اللهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قَدْ جَمَعَ اللهُ لَكَ ذَلِكَ كُلَّهُ
663 صحيح مسلم كتاب المساجد ومواضع الصلاة باب فضل كثرة الخطا إلى المساجد