We propose an efficient scheme for realizing two-mode squeezing for two cavity modes with an atomic ensemble trapped in the cavity and driven by two classical fields. Through a suitable choice of the driving classical fields, the evolution dynamics of the two cavity modes is decoupled with the atomic system and described by a two-mode squeezing operator. We show that a highly squeezed state can be obtained at the output even with a bad cavity. The required experimental techniques are within the scope of what can be obtained in the BEC-cavity setup.