How did Peter recognize Elijah and Moses? Matthew 17:3 Just then there appeared before them Moses and Elijah,
  talking with Jesus.
  
  4 Peter said to Jesus, “Lord, it is good for us to be here. If you
  wish, I will put up three shelters—one for you, one for Moses and one
  for Elijah.”


I am wondering how Peter recognized that the men were Elijah and Moses?

Photographs and portraits didn't exist back in those days. If they did, Peter being a fisherman wouldn't have been to school to see them.

And I doubt Moses and Elijah began their conversation by saying - "Hello Jesus, I am Elijah and this is my buddy Moses."

So how would Peter know it was Elijah standing there?
Short Answer: We don't know.

Some possibilities:


There was some sort of heavenly announcement, similar to the voice of the Father at Jesus' baptism (reference)
Jesus explained it to them, as He was accustomed to having to do for them.  (Keep in mind that there is a lot of stuff that wasn't recorded in Scripture!) (reference)
They recognized it by divine illumination, similar to Peter's recognition of who Jesus really was (reference)
Prior to Peter referencing them by name, it says (in verse 3) that Jesus was talking with them.  Perhaps Jesus called them by name and Peter overheard.


My money is on the last one, since that's the only one that draws clues from the passage itself, but as I said, we really don't know for sure.