599 fix group permissions for ssh

should fix #599 (the group permissions issue).

Also includes some tests.