The best option may depend on where these respondents are coming from and what means you have to contact them.
If you already have a list of email addresses or other contact points for each respondent, you may be able to send each respondent a slightly different URL with a code unique to that respondent. To do this, you would add the same list of passwords to both surveys, then make sure each respondent gets a different password.
If you are unable to send unique links to each respondent, then your idea of creating a code in the first survey and then reading it back in the second survey sounds like a fine option. One way to implement this would be to create a list in the first survey, with at least one unique item for each respondent that may end up taking your survey. At the end of the first survey, you can print out the code for the respective respondent with Sawtooth Script like this:
[% ListLabel(list1, RespNum()) %]
"list1" being the name of the list. Then you can add a password to the second survey and define its accepted values as the contents. Now respondents can only get into the second survey once they've put in the code they got from the first survey.