He heard the Messenger of Allah ﷺ say, "Hosting a guest for one night is an obligation upon every Muslim. If a guest spends the night in someone's courtyard and is denied hospitality, it becomes a debt owed to him. If he wishes, he may claim it, and if he wishes, he may forgive it."
أنه سمع رسول الله ﷺ يقول: ليلة الضيف واجبة على كل مسلم، فإن أصبح بفنائه محروما كان دينا له عليه إن شاء اقتضاه، وإن شاء تركه.
Narrated by Abu Dawud (3750), Ibn Majah (3677), and Ahmad (17172) — the wording is his — and Bukhari in Adab al-Mufrad (744), all of them through various chains, from Mansur (that is, Ibn Mutamir), from Shaybi, from Miqdam bin Mad Yakrib, who mentioned it. Its chain of transmission is sahih.