Ka’b bin al-Ashraf al-Yahoodee was a jew in Al-Madinah who used to recite defamatory poetry about the Prophet صلى الله عليه وسلم and also made explicit poems about the Muslim women. Hence, he was ordered to be killed by the Prophet صلى الله عليه وسلم.
Since you asked this question in the light of the other question about insulting the Prophet صلى الله عليه وسلم, I have to clear up some details about this event in history.
Ka’b bin al-Ashraf returned from Makkah to Madinah and continued reciting such poems. The Prophet صلى الله عليه وسلم was the ruler of al-Madinah and Ka’b bin al-Ashraf was living under his authority in Madinah. And hence he was killed.
The Prophet صلى الله عليه وسلم didn't ask his companions to punish the neighbours of Ka’b bin al-Ashraf or his family members for what Ka'b bin al-Ashraf did. Nor did he harm any representatives of his tribe Banu an-Nadeer, or randomly target the Jews of al-Madeenah nor did he boycott their businesses. Because this will be unjust.
The Prophet صلى الله عليه وسلم as a ruler dealt with Ka'b bin al-Ashraf specifically and punished him for the harm he had done.
Peace means being just. The Prophet صلى الله عليه وسلم was just and carried out the prescribed punishment for the person under his jurisdiction and rule. To show this, I have to mention another incident where the Prophet صلى الله عليه وسلم was insulted but the person who did it was not living under his rule at that particular time.
This is about a man named ‘Abdullah bin Khatal. Many ahadiths mention him. He had two female singers whom he taught to make fun of the Prophet صلى الله عليه وسلم by singing. However, Ibn Khatal was living in Makkah outside the rule of the Prophet صلى الله عليه وسلم . The Prophet صلى الله عليه وسلم did not order his companions to kill him then or harm the kuffar of Makkah or any other town in retribution for defamation and insults of Ibn Khatal because that would be unjust. So he صلى الله عليه وسلم was patient and did not oppress.
So, when he conquered Makkah later, he صلى الله عليه وسلم ordered his companions to kill only few among the people whom he named. Among them were ‘Abdullah bin Khatal and his two singers. He didn't harm their neighbors or family or anyone else. He carried out punishment on only the person who did the crime. And it was done when Makkah came under his rule. Hence, this is the justice.
It is not from the way of Islam to go and carry out punishment on someone who is not living under the rule of Muslims. And it is injustice to harm someone else for the crime of a person.
Source: The Prophet (صلى الله عليه وسلم) cannot by defended by oppression and misguidance