حَدَّثَنَا عُثْمَانُ بْنُ أَبِي شَيْبَةَ، وَعَبْدُ اللَّهِ بْنُ سَعِيدٍ، قَالاَ حَدَّثَنَا أَبُو خَالِدٍ، - يَعْنِي سُلَيْمَانَ بْنَ حَيَّانَ - عَنِ ابْنِ عَجْلاَنَ، عَنْ عَمْرِو بْنِ شُعَيْبٍ، عَنْ أَبِيهِ، عَنْ جَدِّهِ، عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏"‏ إِذَاتَزَوَّجَ أَحَدُكُمُ امْرَأَةً أَوِ اشْتَرَى خَادِمًا فَلْيَقُلِ اللَّهُمَّ إِنِّي أَسْأَلُكَ خَيْرَهَا وَخَيْرَ مَا جَبَلْتَهَا عَلَيْهِ وَأَعُوذُ بِكَ مِنْ شَرِّهَا وَمِنْ شَرِّ مَا جَبَلْتَهَا عَلَيْهِ وَإِذَا اشْتَرَى بَعِيرًا فَلْيَأْخُذْ بِذِرْوَةِ سَنَامِهِ وَلْيَقُلْ مِثْلَ ذَلِكَ ‏"‏ ‏.‏ قَالَ أَبُو دَاوُدَ زَادَ أَبُو سَعِيدٍ ‏"‏ ثُمَّ لْيَأْخُذْ بِنَاصِيَتِهَا وَلْيَدْعُ بِالْبَرَكَةِ ‏"‏ ‏.‏ فِي الْمَرْأَةِ وَالْخَادِمِ
Translation
'Amr b. Shu'aib on his father's authority said that his grandfather (Abdullah ibn Amr ibn al-'As) reported the Prophet (ﷺ) said

When any one of you marries a woman or buys a slave, let him say: 'O Allah, I ask You for her good and the good of that which You have created her upon, and I seek refuge in You from her evil and the evil of that which You have created her upon.' And when he buys a camel, let him take hold of the top of its hump and say the same.

Abu Dawud said: Abu Sa'id added: "Then let him take hold of her forelock and pray for blessing," regarding the woman and the slave.