Sahih Muslim Book 20, Hadith Number 4654.
Chapter : Merit of Jihad and of keeping vigilance (over the enemy).
A version of the tradition narrated on the authority of Ibn Shihab has a little differently worded ending i.e. “A man in a mountain valley.” but did not mention “next to him a man who…”