Petty Officer, Edward Devenney, 30, was told during sentencing at the Old Bailey he had betrayed his country and his colleagues.
Justice Saunders said Devenney knew what he was doing when he met the two men in January.
He added: "He did supply details of movements and operations carried out and to be carried out by nuclear submarines.
"I am satisfied that in the wrong hands it was capable of affecting the operational effectiveness of nuclear submarines.
"This is a very serious case. The defendant was prepared to betray his country and his colleagues."
Devenney, form Northern Ireland, had suffered as the result of a rape allegation of which he was later cleared.
But by January this year, when he met the men in London, Devenney was a "controlled and rational man".
No damage had actually been done to national security because the Russians were in fact MI5 intelligence officers, but Devenney had not known that at the time.
Devenney pleaded guilty to breaching the Official Secrets Act by gathering classified information and misconduct by meeting the supposed spies.
Suggested For You
SUBSCRIBE AND FOLLOW
Get top stories and blog posts emailed to me each day. Newsletters may offer personalized content or advertisements.Learn more