Danger as an excuse for missing congregational Salah
It is permissible for you to offer the Salah in congregation at your posts on the borders. It is not obligatory to go to the Masjid, if leaving your posts will create a danger. If there is no danger, it is obligatory for Salah to be offered in the Masjid, because congregational Salah is obligatory in the Masjid, as evidenced by legal proofs. There is no harm in leaving behind those necessary to guard the post.May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.