The soldiers were attacked as they walked down the main road in Inmaa district, the security official said, adding that the assailants managed to escape.
"They died instantly," he said.
Al-Qaeda controls parts of the port city where the government of President Abedrabbo Mansour Hadi has set up base in its battle against Shiite Huthi rebels.
With support from a Saudi-led coalition, Hadi's forces have driven the rebels out of Aden and four other southern provinces since last July but the Shiite rebels remain in control of the capital Sanaa and much of the north.
They have claimed a string of attacks and assassinations in recent months.