Kaab bin Ujra reported,

The Messenger of Allah ﷺ saw him with lice falling onto his face and asked, "Are these vermin troubling you?"He replied, "Yes."So the Messenger of Allah ﷺ ordered him to shave his head. This was at Hudaybiyah, and it had not yet been made clear to them that they would be released from their state of ihram there, as they were still hoping to enter Makkah. Then Allah revealed the ruling concerning the ransom, and the Messenger of Allah ﷺ ordered him to feed six poor people with a faraq of food, or sacrifice a sheep, or fast for three days.

Bukhari 4159

Sahih

حدثنا الحسن بن خلف قال حدثنا إسحاق بن يوسف عن أبي بشر ورقاء عن ابن أبي نجيح عن مجاهد قال حدثني عبد الرحمن بن أبي ليلى

عن كعب بن عجرة

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

البخاري 4159صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Expeditions
Chapter
Expedition of Hudaybiya
Numbering
Darussalam 4159
Bukhari 4159