As soon as you board the Ebon Hawk at the end of the Peragus level you will be attacked by 25 Sith troopers and need to defend the ship with a retractable blaster cannon a la A New Hope and Jedi Outcast. To get this you need to kill all the troopers before they can board. I recommend just firing as fast as possible in a right-to-left direction as after the first few are killed they will only spawn from the far left. The hit detection is a little spotty so it will probably take several shots to kill each one. You can also shoot the canisters scattered around for some area effect damage.
I recommend you save right before you board just in case you miss one. I've had the game glitch out where the cannon suddenly stopped working and they all boarded. Also, you don't get any xp for killing them with the turret so you might want to get the achievement and then reload for that sweet 200xp per trooper killing the boarders.