sftpdir.c: added authentication method detection.

Stuff copied over from ssh2.c to make testing a bit easier.