We were with the Prophet ﷺ when a man came and whispered something to him.The Prophet ﷺ said, "Kill him."Then he asked, "Does he bear witness that there is no god but Allah?"The man replied, "Yes, but he only says it as a means of protection."The Messenger of Allah ﷺ said, "Do not kill him, for I have been commanded to fight people until they say, 'There is no god but Allah.' Once they say it, their blood and property are safe from me, except for what is rightfully due, and their reckoning is with Allah."
أخبرنا محمد بن عبد الله بن المبارك قال حدثنا الأسود بن عامر قال حدثنا إسرائيل عن سماك
كنا مع النبي ﷺ فجاء رجل فساره فقال اقتلوه ثم قال أيشهد أن لا إله إلا الله قال نعم ولكنما يقولها تعوذا فقال رسول الله ﷺ لا تقتلوه فإنما أمرت أن أقاتل الناس حتى يقولوا لا إله إلا الله فإذا قالوها عصموا مني دماءهم وأموالهم إلا بحقها وحسابهم على الله
Its isnad is sahih. It is found in Sunan al-Kubra, no. 3441. Nasai said, "This hadith of Aswad bin Amir is a mistake, and the correct one is the one that follows it."