Stability of a finite-β inhomogeneous plasma in a sheared magnetic field