This paper examines the interaction between continuously stratified horizontal shear flow and topography. It investigates when topography whose slope changes sign (i.e., a ridge or a trench) destabilizes a shear flow. The instabilities have the form of topographic Rossby waves and rely on the background potential vorticity gradient to exist. Barotropic flow is examined in detail for general horizontal shear over stepped topography and the longwave stratified case is examined in the more specific case of linear shear flow over a top-hat ridge profile. In all cases modes are unstable over significant ranges of the relevant parameters. Stationary unstable modes are seen to correspond to points where two opposing waves are brought simultaneously to rest by the shear flow and propagating unstable modes are seen where opposing waves are brought relatively to rest. Another interpretation of the instabilities in terms of resonance between waves of oppositely signed energy is also explored. Although the greatest growth rates for instabilities occur for the fundamental mode (or external Kelvin wave) interactions, for realistic oceanographic parameters the interactions of the slower moving, higher modes are more likely to be important.