It was the practice of the Prophet (peace and blessings be upon him):
"He (peace and blessings be upon him) would visit the Ansar, greet their children with salam, and pass his hand over their heads."
Hadith Referenceصحیح الجامع الصغیر / حرف الكاف / 4947
Hadith Gradingالألبانی:صحيح
Hadith Takhrij[ن] عن أنس. الصحيحة ١٢٧٨: الطحاوي، حب، حل، خط.