Language:
كتاب الأحكام
93  
Judgments (Ahkaam)
(53)
Chapter: To forbid the criminals and sinners to talk to or visit the ruler
(53)
بَابُ هَلْ لِلإِمَامِ أَنْ يَمْنَعَ الْمُجْرِمِينَ وَأَهْلَ الْمَعْصِيَةِ مِنَ الْكَلاَمِ مَعَهُ وَالزِّيَارَةِ وَنَحْوِهِ
Sahih al-Bukhari 7225

Narrated `Abdullah bin Ka`b bin Malik:

Who was Ka`b's guide from among his sons when Ka`b became blind: I heard Ka`b bin Malik saying, "When some people remained behind and did not join Allah's Messenger (ﷺ) in the battle of Tabuk.." and then he described the whole narration and said, "Allah's Messenger (ﷺ) forbade the Muslims to speak to us, and so we (I and my companions) stayed fifty nights in that state, and then Allah's Messenger (ﷺ) announced Allah's acceptance of our repentance."

حَدَّثَنِي يَحْيَى بْنُ بُكَيْرٍ، حَدَّثَنَا اللَّيْثُ، عَنْ عُقَيْلٍ، عَنِ ابْنِ شِهَابٍ، عَنْ عَبْدِ الرَّحْمَنِ بْنِ عَبْدِ اللَّهِ بْنِ كَعْبِ بْنِ مَالِكٍ، أَنَّ عَبْدَ اللَّهِ بْنَ كَعْبِ بْنِ مَالِكٍ ـ وَكَانَ قَائِدَ كَعْبٍ مِنْ بَنِيهِ حِينَ عَمِيَ ـ قَالَ سَمِعْتُ كَعْبَ بْنَ مَالِكٍ، قَالَ لَمَّا تَخَلَّفَ عَنْ رَسُولِ اللَّهِ صلى الله عليه وسلم فِي غَزْوَةِ تَبُوكَ ـ فَذَكَرَ حَدِيثَهُ ـ وَنَهَى رَسُولُ اللَّهِ صلى الله عليه وسلم الْمُسْلِمِينَ عَنْ كَلاَمِنَا، فَلَبِثْنَا عَلَى ذَلِكَ خَمْسِينَ لَيْلَةً، وَآذَنَ رَسُولُ اللَّهِ صلى الله عليه وسلم بِتَوْبَةِ اللَّهِ عَلَيْنَا‏.‏
Reference : Sahih al-Bukhari 7225
In-book reference : Book 93, Hadith 84
USC-MSA web (English) reference : Vol. 9, Book 89, Hadith 331
  (deprecated numbering scheme)