Gog is first mentioned in I Chronicles 5:4. In this context, he is one of the sons of Joel, a descendant of Reuben. This is all we hear about anyone named Gog until Ezekiel 38.
Magog is mentioned in Genesis 10:2 as one of the grandsons of Noach (Noah). I Chr 10 is an exact copy of Gen 10:2 in English, I have no reason to assume the Hebrew is any different.
Again there is no mention of Magog in Scripture until Ezekiel 38.
In the original context, both Gog and Magog are men and appear to have no connection to one another.
The Magog of Ezekiel 38 is a country. The Gog of Ezekiel 38 is called the 'chief prince' of not the land of Magog, but Meschech and Tubal. (38:3) The interesting word here is not chief (Rosh), but prince. While in some other places, the word sar is used, in this context the word nasi is used. Its primary meaning is chief, prince, captain or leader.
It's used of Abraham (Gen 23:6). The secondary meaning though is highly interesting. "Vapors which ascend from the earth, from which the clouds are formed."
That isn't the only time the LORD uses the word ascend in the passage. He tells Gog that He will bring him 'up'. Ascend from where? The north parts or north quarter. (Ez 39:2) The word for north is tsaphon. This is yet another interesting word. The ancient people regarded the north as dark and obscure. (Like a bottomless pit perhaps?)
Rev 20:8 tells us that Satan is loosed from his prison (the bottomless pit, a notably dark and obscure place, often associated with death [Sheol]) and he comes out with one thing in mind:
Rev 20:8 And shall go out to deceive the nations which are in the four quarters of the earth, Gog and Magog, to gather them together to battle: the number of whom [is] as the sand of the sea.
Could John be trying to tell us something here? Personally, I think so. Ezekiel's Gog and Magog and John's Gog and Magog have certain similarities, but they aren't exactly the same.
Both accounts mention certain things though. Gog comes against the people of God; in Ezekiel, it's the land of Israel, in Revelation, it's the camp of the saints, the Holy City. He comes up and covers Israel like a cloud over the land; he surrounds the saints in Rev 20:8. The concepts are close to the same, the people of God are hemmed in. It's God who rescues them in both cases, in Ezekiel with fire and brimstone from heaven, in Revelation with fire from heaven (judgment day).
The differences? In the Ezekiel account, Israel survives and has to employ professionals to clean up the mess. In Revelation, no one survives. The resurrection and rapture occur for saints and the resurrection of the wicked unto judgment takes place. Peter tells us that the heavens melt with fervent fire and the earth and all its works are burned up. (2 Peter)
Gog is Satan himself. He is the 'chief prince' of the heathen (Magog). They have been surrounding us (the holy city, the camp of the saints) for years and we in our sheep-ness have been off eating poor food served up by self-effacing and self-serving shepherds. They're hirelings.