Issue
I want to validate a user submitted public key in php. I want something equivalent to ssh-keygen -lf
command.
I've tried href="https://github.com/violuke/rsa-ssh-key-fingerprint" rel="nofollow noreferrer">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?
Solution
Try load your key using RSA::loadKey
from phpseclib.
If it succeeds, the key should be valid.
Answered By - Martin Prikryl Answer Checked By - Marilyn (WPSolving Volunteer)