I want to validate a user submitted public key in php. I want something equivalent to ssh-keygen -lf
command.
I've tried violuke/rsa-ssh-key-fingerprint, but unlike ssh-keygen -lf
, it does not say if public key is valid or not. It returns a hash regardless of key being valid or not.
How can I validate public key in PHP?
Try load your key using PublicKeyLoader::load
from phpseclib.
If it succeeds, the key should be valid.