If we are talking about what happened before the first enter of Gagarin into the Vostok. I would use perfective aspect: Каждый пожал космонавту руку, обнял, пожелал успеха.
But if there were a lot of persons who shook Gagarin's hand and every shaking took a long time the imperfective aspect is also acceptable: Каждый пожимал космонавту руку, обнимал, желал успеха.
However, the perfective aspect is more suitable here.