It happened, when Joshua was by Jericho, that he lifted up his eyes and looked, and, behold, there stood a man over against him with his sword drawn in his hand: and Joshua went to him, and said to him, Are you for us, or for our adversaries?
The command to remove his sandals (Joshua 5:15) would have convinced Joshua that this was the same God who appeared to Moses at the burning bush (Exodus 3:5).