كتاب الإمارة
33  
The Book on Government
(8)
Chapter: The obligation of obeying leaders in matters that do not involve sin, but it is forbidden to obey them in sinful matters
(8)
باب وُجُوبِ طَاعَةِ الأُمَرَاءِ فِي غَيْرِ مَعْصِيَةٍ وَتَحْرِيمِهَا فِي الْمَعْصِيَةِ ‏‏
Sahih Muslim 1840 c

This hadith has been transmitted on the authority of A'mash.

وَحَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا وَكِيعٌ، وَأَبُو مُعَاوِيَةَ عَنِ الأَعْمَشِ، بِهَذَا الإِسْنَادِ نَحْوَهُ ‏.‏
Reference : Sahih Muslim 1840c
In-book reference : Book 33, Hadith 65
USC-MSA web (English) reference : Book 20, Hadith 4537
  (deprecated numbering scheme)