main, sshd: Refactor authentication, add IP throttling, improve passphrase auth
authormik2k2 <44849223+mik2k2@users.noreply.github.com>
Mon, 31 May 2021 14:08:30 +0000 (16:08 +0200)
committerGitHub <noreply@github.com>
Mon, 31 May 2021 14:08:30 +0000 (10:08 -0400)
commit7413539965622ba07e8cd3719fc9d545fb52c5fd
treedc090119056459ca4709757c6af58d2c129a7b01
parentc3b589b2861e51b19325eb3d7cc4480d3834c4ea
main, sshd: Refactor authentication, add IP throttling, improve passphrase auth

* Move password authentication handling into sshd/auth (fixes #394).

Password authentication is now completely handeled in Auth. The normal
keyboard-interactive handler checks if passwords are supported and asks
for them, removing the need to override the callbacks.

Brute force throttling is removed; I'd like to base it on IP address
banning, which requires changes to the checks.

I'm not sure, but I think timing attacks against the password are fixed:
- The hashing of the real password happens only at startup.
- The hashing of a provided password is something an attacker can do
themselves; It doesn't leak anything about the real password.
- The hash comparison is constant-time.

* refactor checks, IP-ban incorrect passphrases, renames

- s/assword/assphrase/, typo fixes
- bans are checked separately from public keys
- an incorrect passphrase results in a one-minute IP ban
- whitelists no longer override bans (i.e. you can get banned if you're
whitelisted)

* (hopefully) final changes
auth.go
auth_test.go
cmd/ssh-chat/cmd.go
sshd/auth.go
sshd/client_test.go