Once when Jesus was praying in solitude, and the disciples were with him, he asked them, "Who do the crowds say that I am?" They said in reply, "John the Baptist; others, Elijah; still others, 'One of the ancient prophets has arisen.'" Then he said to them, "But who do you say that I am?" Peter said in reply, "The Messiah of God." He rebuked them and directed them not to tell this to anyone. He said, "The Son of Man must suffer greatly and be rejected by the elders, the chief priests, and the scribes, and be killed and on the third day be raised." (Lk 9:18-22)
Jesus was praying in solitude. Praying is personal. Praying is a mystery. Prayer is relationship between God and the one praying. That is the reason why Gospel presents Jesus as going alone to a secluded place (mountain) to pray. When Jesus was praying his disciples were watching him praying. Jesus also becomes a model for the disciples.
Jesus was considered to be a prophet by the people. Jesus’ way of preaching and doing reminded the people of prophet. Prophets always preached about God and his justice towards the people. Prophets also demanded justice among people themselves. Jesus’ ministry was one of preaching God and his kingdom and working for justice among the people.
Peter said that Jesus was the Messiah. This is the revelation from God. Jesus did not want this to be made public. It could be that the people expected a different type of Messiah. Jesus was saying that he would suffer greatly, be rejected and be killed. People would not be able to accept it until after resurrection. This could have been the reason why Jesus wanted this to be kept secret until the resurrection.