An H-bomb can deflect asteroids in vacuum, because a sizable fraction of the explosive energy produces a wall of high-energy radiation and high temperature atoms at millions of degrees. This high temperature stuff heats the surface layers, and throws the material off the surface into space. The recoil from this ablation process makes a rocket, and this type of rocket pressure is effective enough to lift payloads of thousands of tons into space.
The way to estimate the thrust provided by atomic devices, arranged optimally, is to consider the orion spacecraft estimates. According to wikipedia, 800 bombs of size .15 kT (altogether only 100kT of bomb yield) will boost 4,000 tons into orbital velocity (a few km/s) in 10 minutes of explosions. A km scale asteroid is a million times more massive, so to deflect it's path by 10,000 km with the same explosive yeild would take many years.
With 50 mT of explosive yeild, you can reduce the time for deflection by a factor of 500, so you only need a few month's warning. But this is not going to work with a single big bomb, because a single big bomb will waste a lot of it's energy. But you should be able to deflect an 1km asteroid with less than a year's notice using one hundred small (like 50kT) nuclear devices planted one by one inside the surface a little and detonated, and then you would make an orion style deflector. This is a fine method, but considering that large asteroid impacts occur on a once in a million year time scale, we don't have much to worry about.
The distances involved are so large that there would be no effect on the Earth.