The FSB said the assailant entered the building and opened fire at people in the reception area before going through security control in the April 21 attack, Russian news agencies reported.
It said the attacker fatally shot an FSB officer and a visitor and also wounded another visitor before being killed by FSB personnel.
The two visitors were from a former Soviet republic other than Russia, the FSB said.
The FSB said the attacker was a local who was born in 1999 and might have had links to neo-Nazi activities. It gave his last name, Konev, and the initials A.V.
The FSB is Russia's main domestic security and intelligence agency.
Based on reporting by Republic, TASS, and Interfax