I have some doubts regarding keys passphrases

  1. I have many machines (around 5) where I use ssh from
  2. Every machine has different password for user
  3. I log in from every machine to any other machine

So it gives 25 keypairs I guess and the thing is - what should be passphrase to keys? I see following solutions:

  • use local machine password
  • use remote machine password
  • use combined pass like "localpassremotepass"
  • use different passphrase for every keypair (pretty unusable. Number of passwords grows exponentially)

Local machines are much more likely to get compromised than remote.

Which of those strategies is correct as in widely used and accepted as fine? Are there any other solutions like some hybrids etc?

3 Answers 3


First, you should look into the ssh-agent and the ssh option -A (ForwardAgent).

This might simplify your life a bit because it allows you to have the keys unlocked at the terminal where you are working, but use them at remote locations.

Secondly, I would recommend that your key-password not be the same as your login password. Having the key-password the same as your login password means that an attacker (or bad actor) who gets your login password gets access to all your machines.

Having different login passwords for each machine is probably a good idea.

Having a different key for each machine is probably not that useful for you. Having a single key that authorizes all your machines is probably your best bet for an initial configuration.

Open-SSH now has support certificates if you want finer-grained control, however, that is more complicated to set up, so I would recommend you start with the simple configuration initially.

  • Use some kind of identity management/LDAP if you plan to grow the amount of machines. Storing private keys on remote machines you don't have physical access is never good idea.

  • You can quite simply use a single keypair for each machine you are connecting from. In this case you will not get the exponential grow. If one machine gets compromised, you can wipe corresponding public key from the other machines to "cut it off" (IdM can do it centrally)

  • Introducing some logic in passwords/passphrases is always bad. It is based on the attacker not knowing the logic (security through obscurity). In your case, if the attacker would know one password to one of your machines, he would have half of passwords to all your systems -- offline attack goes faster than online.

  • Passphrase is not password as the name is trying to point out. It should be way longer than regular password (doubling the size using two password is quite the bottom limit for the passphrase).


Several options:

  1. If you use a single workstation to access all machines, you can use one key pair to login from any machines to any machines interactively. You should set up a ssh ForwardAgent, which allows you to authenticate from a machine without transferring your key. The authentication and signing all happens in your workstation

  2. Designate one of the machine as a jump server. The jump server is your access point to all other machines and have your encrypted key. To login to any machines, you first login to the jump server, and you use the key you keep in the jump server to login to other machines. If you choose this solution, you might want to enforce firewall/IP filtering so the other machines can only be accessed from the jump server

  3. If you are mobile and need to login from different machines, you want to keep your key with you. You can purchase an OpenPGP smartcard/USB token and setup SSH to authenticate using the smartcard/USB key. For example: https://www.grepular.com/Smart_Cards_and_SSH_Authentication

  4. You can set up SSH Certificates. Install one Root certificate to each machine, and the machines will trust any keys signed by the root certificate. For example: https://www.digitalocean.com/community/tutorials/how-to-create-an-ssh-ca-to-validate-hosts-and-clients-with-ubuntu

You must log in to answer this question.

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