6

Is it safe to have the same passphrase for the main (and only, in my case) ssh key as the user login-password to the computer I use on daily basis? Assuming I am the only user of that computer. What are the potential security risks?

4 Answers 4

4

Generally speaking, reusing passwords is a bad idea unless you're using the same password in the same realm, i.e. among machines or services that are administered by the same group, and where people who have access to one of the machines/services generally have access to all of them.

The password on your account on machine A is used on machine A and controls access to machine A. The password on your SSH private key on machine A is used on machine A and controls access to other machines. If you use the same password on both and it is leaked, this compromises both machine A and other machines. Therefore sharing the password is a bad for security.

The password on your account on machine A is used on machine A and controls access to machine A. The password on your SSH private key on machine B is used on machine B and controls access to machine A. If you use the same password on both, then it can be leaked from either A or B. Therefore sharing the password is bad for security.

The password may also leak through backups. For example, if a backup of your home directory is compromised (or you accidentally upload your private key file to Github — you wouldn't be the first¹), the attacker has access to the key file. The OpenSSH private key file format is vulnerable to brute force attacks on the password. Since OpenSSH 6.5, there is a new format (selected with ssh-keygen -o which properly uses a slow hash, but it isn't used by default as of OpenSSH 7.7. So if an attacker gains access to your key file, there's a serious risk that they'll get the password, which lets them use the key and lets them log in without the key. Even with a slow hash, if your password is too weak, an attacker who has the key file may be able to crack it offline (i.e. limited only by how much electricity they're willing to spend).

For these reasons, you should not use the same password for an SSH key and for a user account. If you want to protect the key file but you don't want to remember a separate password, it would be better to use a non-memorable password and store it in your keyring (the Gnome keyring does use a slow hash).²

¹ I think Github now protects against directly uploading the key file.
² And do remember not to leak backups of your keyring, but that's less of a problem than with SSH in practice because people tend to back up their .ssh directory which contains configuration files such as config and authorized_keys.

2
  • I wonder that you recommend different passwords in general but then using also Gnome keyring which protects even more passwords by just one master password. BTW Gnome keyring is IMO a terrible program which has a lot unfixed of bugs and also does not support all ssh key algorithms.
    – rudimeier
    Commented May 11, 2018 at 7:31
  • @rudimeier Gnome-keyring has many downsides, but from reading the documentation (I haven't audited the code) it protects the password database better than OpenSSH does out of the box. It is more secure if you use a different, more complex passphrase for the keyring than for logging in, but that's not the out-of-the-box configuration and is problematic for ordinary users. Commented May 11, 2018 at 20:29
1

The answer to this question really depends on your computing environment. Are you asking this question as a consumer (home) user or are you asking this question as an enterprise user (work). If you are asking in the voice of the latter then I would first recommend that your consult your system administrator and/or your corporate internal security policies. As a whole, I would say (from the prospective of a IA practitioner...the answer is always no. I would recommend using a password manager and encrypt the master list with an application such as veracrypt.

-1

In general, reusing passwords is a bad and unsafe idea.

You need to evaluate the risks vs. the simplicity of using the same password considering what your SSH key is used for. Do you encrypt sensitive information with it? Access remote test servers? Production servers? That's something only you can assess.

Having separate passwords means implementing defense in depth: should someone find your password and access your computer, they still won't able to use your SSH key.

4
  • 1
    In case somebody has already access to the user's account, then it's very likely that he would find out the passphrase anyways, by spying the user when he is typing it or just using a running ssh-agent. Of course you are right about the "general message".
    – rudimeier
    Commented May 9, 2018 at 13:02
  • I disagree about "very likely".
    – dr_
    Commented May 9, 2018 at 13:06
  • The attacker using your account could manipulate your env, ssh client and even your shell. I don't believe that you check all that, each time before using ssh client. And there are even more ways to fish your input or unencrypted keys from memory.
    – rudimeier
    Commented May 9, 2018 at 15:58
  • @rudimeier But that's not the only problematic scenario by far. Commented May 9, 2018 at 20:04
-1

It's common knowledge that one should always use different passwords for different purpose. However in this case I would say the risk is low, at least if ssh login via password is disabled on your workstation, so that a remote attacker cannot have any benefit of knowing your password at all.

In case you have already a local intruder (knowing your password), then he could easily setup things to spy you out to get your passphrase whenever you type it again. Many users have ssh-agent running anyways so an intruder could use it without the need for a password at all. So different passwords would not help much here but maybe could still protect you against "known non-expert" attackers, like your kids, mother in law, etc. ;)

A more interesting case would be that a remote attacker (virus) managed to execute code on your user account without knowing any password yet. It seems easier for him to spy out your key-passphrase. But would it be important for him to get the system password if he has already access? Maybe to use sudo, when it's setup like in Ubuntu by default.

Another case would be that the attacker has only access to the files /etc/shadow and/or the encrypted ssh-keys (e.g. break in to the backup server). Now in theory it's possible that either the keys or the shadow files are less secure against brute-force attacks to guess passwords. This would be an advantage for the attacker, but I guess this advantage is low.

2
  • There are other problematic scenarios, especially an attacker gaining hold of a backup of the private key file. And you didn't consider the fact that the SSH key and the password proect different systems. Commented May 9, 2018 at 20:05
  • @Gilles Actually I have mentioned the backup leak and I'm also aware that the password protects different systems. Though I silently assumed that ssh login via password is disabled on the machine. I will add this to my answer.
    – rudimeier
    Commented May 11, 2018 at 7:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .