Abu Qatada reported,

From the Prophet ﷺ. And Sulayman bin Abdul-Rahman narrated to me, Walid narrated to us, Uzai narrated to us, saying Yahya bin Abu Kathir narrated to me, saying Abdullah bin Abu Qatada narrated to me, from his father, who said,The Prophet ﷺ said, "The good dream is from Allah, and the bad dream is from Satan. So when one of you has a dream that frightens him, let him spit to his left and seek refuge with Allah from its evil, and it will not harm him."

Bukhari 3292

Sahih

حدثنا أبو المغيرة حدثنا الأوزاعي قال حدثني يحيى

عن عبد الله بن أبي قتادة عن أبيه

عن النبي ﷺ ح و حدثني سليمان بن عبد الرحمن حدثنا الوليد حدثنا الأوزاعي قال حدثني يحيى بن أبي كثير قال حدثني عبد الله بن أبي قتادة عن أبيه قال قال النبي ﷺ الرؤيا الصالحة من الله والحلم من الشيطان فإذا حلم أحدكم حلما يخافه فليبصق عن يساره وليتعوذ بالله من شرها فإنها لا تضره

البخاري 3292صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Beginning of creation
Chapter
Description of Iblis and his soldiers
Numbering
Darussalam 3292
Bukhari 3292