The Door to Moria

Oh Wizard Gray, puzzled at long last
The Moria door remains shut fast.
Knocked by staff and cast with spell,
Still no secrets does it tell.
Elvish word, some kind of riddle
Password spoken, opens in the middle.
What word will move a door of stone,
So nine can enter, leaving one alone.
Frightened by the Watcher, the pony runs away,
Speak "FRIEND" and enter Gandalf the Gray.
The door snaps open, the company runs in.
Stones crash, rocks smash, the door is closed again!