This article is from the FAQ, by with numerous contributions by others.
You do not have to be a permanent resident (or any kind of resident)
to get a Social Security retirement benefit. It can be paid to
a person living outside the US who does not have any kind of
US visa. The requirement is to have paid a certain amount of
Social Security tax, in the US, for at least 10 years. Of
course it is difficult to work legally in the US for as much
as 10 years without getting a green card. But it is possible,
and also a person who maintains PR for 10 years, then leaves
the US and abandons PR status, is eligible for a Social
Security retirement benefit.
 
Continue to: