Shubayl bin Azrah (may Allah have mercy on him) said: Qatadah (may Allah have mercy on him) and I went to Sayyiduna Anas bin Malik (may Allah be pleased with him), and Sayyiduna Anas bin Malik (may Allah be pleased with him) told us that the Messenger of Allah (peace and blessings be upon him) said: "The example of a righteous companion is like that of a perfume seller: even if you do not get anything (directly) from him, his fragrance will surely reach you. And the example of an evil companion is like that of a blacksmith: even if nothing (no spark or soot) from him touches you, his smoke will surely reach you."
Imam Abu Dawud (may Allah have mercy on him) narrated it through Abdullah bin al-Sabbah al-Attar, Sa'id bin Amir and Shubayl.