Adding a password to your SSH key means that the private key will be stored encrypted on your local machine. That private key is a rather sensitive secret since knowing that key grants access to all servers on which you registered the corresponding public key (in your
Secrets in local files can be plundered by attackers in various occasions:
- Your laptop is stolen.
- Your harddisk breaks down (it happens) and you discard it, and the attacker retrieves it from your dumpster, repairs it (e.g. the broken part was the electronic board, and the attacker simply replaces it), and reads your files.
- You make a backup of your files on some external device (USB drive, tape...) and the attacker steals it.
- Some malware on your machine takes a peek at your files and uploads your private keys to a server in Uzbekistan.
- Through some unfortunate configuration mishap, you make your files available to the world at large (e.g. with disk sharing, or with a local Web server which was not correctly setup).
This list is not exhaustive. In all these occasions, password-based encryption of your SSH private key will make the life harder for the attacker. Note that your files are likely to contain other sensitive information as well, so SSH private key encryption is not sufficient to reach the beatitude of absolute security; however, it helps.
Of course, there is nothing completely free. If you use a password to protect the on-disk storage of your private key, then you will have to type that password on a regular basis. As usual, security and convenience are two sides of a trade-off.