Ssh – How to limit connections to OpenSSH server to using private keys necessarily with passphrase

opensshSecurityssh

Is there any way to configure OpenSSH (/etc/ssh/sshd_config) server to allow private keys necessarily with passphrase?

Best Answer

No, you have little control over how the private keys are configured, and you can't detect / enforce any passphrase requirement on them.

You also can't limit the size of the keys without modifying the OpenSSH source itself (i.e. there is no configuration option to achieve a minimum key length limit).

You can limit the type of public keys accepted using the PubkeyAcceptedKeyTypes parameter, but not the length.

PubkeyAcceptedKeyTypes

Specifies the key types that will be accepted for public key authentication as a comma-separated pattern list. Alternately if the specified value begins with a `+' character, then the specified key types will be appended to the default set instead of replacing them. The default for this option is:

  ecdsa-sha2-nistp256-cert-v01@openssh.com,
  ecdsa-sha2-nistp384-cert-v01@openssh.com,
  ecdsa-sha2-nistp521-cert-v01@openssh.com,
  ssh-ed25519-cert-v01@openssh.com,
  ssh-rsa-cert-v01@openssh.com,
  ssh-dss-cert-v01@openssh.com,
  ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,
  ecdsa-sha2-nistp521,ssh-ed25519,
  ssh-rsa,ssh-dss
Related Question