Merge pull request #2540 from JohnMaguire/bugfix/2447-delete-public-key-authorized_keys
Fixes #2447 (delete public key from authorized_keys)
This commit is contained in:
commit
32efc3ec0a
|
@ -165,6 +165,9 @@ func CheckPublicKeyString(content string) (_ string, err error) {
|
||||||
return "", errors.New("only a single line with a single key please")
|
return "", errors.New("only a single line with a single key please")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove any unnecessary whitespace now
|
||||||
|
content = strings.TrimSpace(content)
|
||||||
|
|
||||||
fields := strings.Fields(content)
|
fields := strings.Fields(content)
|
||||||
if len(fields) < 2 {
|
if len(fields) < 2 {
|
||||||
return "", errors.New("too less fields")
|
return "", errors.New("too less fields")
|
||||||
|
@ -374,6 +377,11 @@ func rewriteAuthorizedKeys(key *PublicKey, p, tmpP string) error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !isFound {
|
||||||
|
log.Warn("SSH key %d not found in authorized_keys file for deletion", key.ID)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue