Ka'b al-Ahbar (may Allah have mercy on him) swore by Allah, who split the sea for Musa (peace be upon him), that Sayyiduna Suhayb (may Allah be pleased with him) told him that whenever the Messenger of Allah (peace and blessings be upon him) intended to enter a town, he would say on seeing it: "O Allah, Lord of the seven heavens and Lord of all that they shade, Lord of the seven earths and Lord of all that they carry, Lord of the devils and Lord of all whom they lead astray, Lord of the winds and Lord of all that they scatter! We ask You for the good of this town and the good of its people, and we seek refuge in You from its evil and the evil of its people."
Hadith Referenceالمعجم الكبير للطبراني / باب الصاد / 7268