Rewrite sshkey security plugin

Added unit tests. Cleaned up some bugs.