Abu Malik al-Ash'ari reported God's messenger as saying that when a man goes into his house he should say, “O God, I ask Thee for good both when entering and when going out; in the name of God we have entered and in God our Lord do we trust.” He should then greet his family.
Abu Dawud transmitted it.