كتاب الإيمان
1  
The Book of Faith
(67)
Chapter: Permissibility of concealing one's faith in the case of fear
(67)
باب جَوَازِ الاِسْتِسْرَارِ لِلْخَائِفِ ‏‏
Sahih Muslim 149

Hudhaifa reported:

We were in the company of the Messenger of Allah (ﷺ) when he said. Count for me those who profess al-Islam. We said: Messenger of Allah, do you entertain any fear concerning us and we are (at this time) between six hundred and seven hundred (in strength). He (the Holy Prophet) remarked: You don't perceive; you may be put to some trial, He (the narrator) said: We actually suffered trial so much so that some of our men were constrained to offer their prayers in concealment.
حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، وَمُحَمَّدُ بْنُ عَبْدِ اللَّهِ بْنِ نُمَيْرٍ، وَأَبُو كُرَيْبٍ - وَاللَّفْظُ لأَبِي كُرَيْبٍ - قَالُوا حَدَّثَنَا أَبُو مُعَاوِيَةَ، عَنِ الأَعْمَشِ، عَنْ شَقِيقٍ، عَنْ حُذَيْفَةَ، قَالَ كُنَّا مَعَ رَسُولِ اللَّهِ صلى الله عليه وسلم فَقَالَ ‏"‏ أَحْصُوا لِي كَمْ يَلْفِظُ الإِسْلاَمَ ‏"‏ ‏.‏ قَالَ فَقُلْنَا يَا رَسُولَ اللَّهِ صلى الله عليه وسلم أَتَخَافُ عَلَيْنَا وَنَحْنُ مَا بَيْنَ السِّتِّمِائَةِ إِلَى السَّبْعِمِائَةِ قَالَ ‏"‏ إِنَّكُمْ لاَ تَدْرُونَ لَعَلَّكُمْ أَنْ تُبْتَلَوْا ‏"‏ ‏.‏ قَالَ فَابْتُلِينَا حَتَّى جَعَلَ الرَّجُلُ مِنَّا لاَ يُصَلِّي إِلاَّ سِرًّا ‏.‏
Reference : Sahih Muslim 149
In-book reference : Book 1, Hadith 284
USC-MSA web (English) reference : Book 1, Hadith 275
  (deprecated numbering scheme)