sudo apt-get autoremove --purge
This command will usually keep the last 3 kernels in the partition, which is good in case anything goes wrong with the current kernel.
If Linux is still complaining that the boot partition is running out of space, try the option below.
Get only the kernels (and depencies) that are not currently being used:
dpkg --list "linux-image*" | grep -v ^ii
Delete them one by one. Example:
sudo apt-get purge linux-image-4.10.0-28-generic