For how long do I have to have worked in Germany to become eligible for a pension?

You must have worked for a certain amount of time within the current borders of Germany. The minimum qualifying period depends on the applicable pension agreement between Germany and your country of residence