-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSH key validation #108
base: master
Are you sure you want to change the base?
SSH key validation #108
Conversation
Thanks a lot, I will look at it. |
Just pushed an update, because somehow I forgot functions.inc.php :/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other types of keys need to be considered before merging this. Also unit testing of the function that validates the keys would be greatly appreciated.
echo "<div class=\"help alert alert-warning\">\n"; | ||
echo "<p>".$messages["sshkeypolicy"]."</p>\n"; | ||
echo "<ul>\n"; | ||
if ( $sshkey_min_bits ) { echo "<li>".$messages["sshkeypolicyminbits"] ." $sshkey_min_bits</li>\n"; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are uneeded extra spaces here.
@@ -239,6 +260,29 @@ function check_password_strength( $password, $oldpassword, $pwd_policy_config, $ | |||
return $result; | |||
} | |||
|
|||
function check_sshkey( $ssh_pubkey, $sshkey_policy_config ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function needs unit testing with different keys and policies.
$parts = explode(' ', $ssh_pubkey); | ||
|
||
# Check this gave us at least two parts, and SSH key type is valid | ||
if (count($parts) < 2 || $parts[0] != 'ssh-rsa') { return "keyinvalid"; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function considers all non rsa keys as invalid. I do not think it is acceptable to disallow other types of keys : dsa, ecdsa and ed25519.
Completely forgot about this, I'll look into it soon. :P |
I updated the SSH Key page to support key bit size checking, as well as some updates for better wording.
I have not yet done the additional languages. I can do that in a separate pull request if desired, though be warned it will be through Google Translate. ;)
Edit: Looks like I have to do translations. @_@ Ok, one moment...