We used to say during prayer behind the Messenger of Allah ﷺ, "Peace be upon Allah, peace be upon so-and-so."One day the Messenger of Allah ﷺ said to us, "Allah Himself is Peace. When one of you sits during the prayer, let him say, 'All greetings, prayers, and good things are for Allah. Peace be upon you, Prophet, and the mercy of Allah and His blessings. Peace be upon us and upon the righteous servants of Allah.' When he says this, it reaches every righteous servant of Allah in the heavens and the earth. 'I bear witness that there is no god but Allah, and I bear witness that Muhammad is His servant and messenger.' Then let him choose whichever supplication he wishes."
كنا نقول في الصلاة خلف رسول الله ﷺ: السلام على الله، السلام على فلان، فقال لنا رسول الله ﷺ ذات يوم: إن الله هو السلام، فإذا قعد أحدكم في الصلاة، فليقل التحيات لله، والصلوات والطيبات، السلام عليك، أيها النبي ورحمة الله وبركاته، السلام علينا، وعلى عباد الله الصالحين.- فإذا قالها أصابت كل عبد الله، صالح في السماء والأرض-، أشهد أن لا إله إلا الله، وأشهد أن محمدا عبده ورسوله، ثم يتخير من المسألة ما شاء.
Bukhari narrated it in the Book of Supplications (6328), and Muslim in the Book of Prayer (402), both from Uthman bin Abu Shayba, from Jareer, from Mansur, from Abu Waail, from Abdullah bin Masud, and he mentioned it. The wording given is Muslim's.Bukhari also narrated it in the Book of Seeking Permission (6265), and this is his wording, and Muslim in the Book of Prayer (402:59), both from the hadith of Abu Naeem, who said, Sayf bin Sulayman narrated to us, who said, I heard Mujahid say, Abdullah bin Sakhbara narrated to me, he said, I heard Ibn Masud say, "The Messenger of Allah ﷺ taught me the tashahhud, with my hand between his two hands, just as he would teach me a surah from the Quran," and he mentioned the same up to his words, "and I bear witness that Muhammad is the Messenger of Allah." He said, "And he was among us. When he passed away, we would say, 'peace,'" meaning upon the Prophet ﷺ. That is, they dropped the direct address and mentioned it in the third-person form.It is established as sahih from the companions of the Prophet that they used to say, while the Prophet ﷺ was alive, "Peace be upon you, O Prophet." Then when he died, they said, "Peace be upon the Prophet."Abdul-Razzaq narrated it, saying, from Ibn Jurayj, from Ataa, that the companions of the Prophet ﷺ used to say, and he mentioned it. Ibn Jurayj, although he practiced tadlis, his narration from Ataa is taken to be based on direct hearing, as Ibn Jurayj himself stated. Ibn Hajar also graded its chain sahih in Fath al-Bari (2/314).So his statement, "the companions of the Prophet," means some of the companions of the Prophet ﷺ, because Umar bin Khattab used to teach the tashahhud from the pulpit in the presence of a gathering of the companions, and he mentioned in it, "Peace be upon you, O Prophet," as will come later, and no one objected to him over it.