My ears heard and my heart retained that whoever claims to belong to someone other than his father, knowing he is not his father, paradise is forbidden to him.He said, "I met Abu Bakrah and related this to him, and he said, 'My ears too heard it and my heart retained it from Muhammad ﷺ.'"
حدثنا إسماعيل حدثنا عاصم الأحول عن أبي عثمان النهدي قال سمعت
سمعت أذناي ووعى قلبي أن من ادعى إلى غير أبيه وهو يعلم أنه غير أبيه فالجنة عليه حرام قال فلقيت أبا بكرة فحدثته فقال وأنا سمعت أذناي ووعى قلبي من محمد ﷺ
Its isnad is sahih. Bukhari narrated the hadith with similar wording, 12/54 in Fath al-Bari, in the chapters on inheritance, on one who claims descent from someone other than his father, and Muslim, 1/80, no. 63, in the chapters on faith, and Abu Dawud, 4/333, no. 5115, and Ibn Majah, 2/870, no. 2610.