72 Commits

Author SHA1 Message Date
mik2k2
621ae1b0d3
Add /allowlist command (#399)
* move loading whitelist+ops from file to auth and save the loaded files fro reloading

* add /whitelist command with lots of open questions

* add test for /whitelist

* gofmt

* use the same auth (the tests don't seem to care, but htis is more right)

* mutex whitelistMode and remove some deferred TODOs

* s/whitelist/allowlist/ (user-facing); move helper functions outside the handler function

* check for ops in Auth.CheckPublicKey and move /allowlist handling to helper functions

* possibly fix the test timeout in HostNameCollision

* Revert "possibly fix the test timeout in HostNameCollision" (didn't work)

This reverts commit 664dbb0976f8f10ea7a673950a879591c2e7c320.

* managed to reproduce the timeout after updating, hopefully it's the same one

* remove some unimportant TODOs; add a message when reverify kicks people; add a reverify test

* add client connection with key; add test for /allowlist import AGE

* hopefully make test less racy

* s/whitelist/allowlist/

* fix crash on specifying exactly one more -v flag than the max level

* use a key loader function to move file reading out of auth

* add loader to allowlist test

* minor message changes

* add --whitelist with a warning; update tests for messages

* apparently, we have another prefix

* check names directly on the User objects in TestHostNameCollision

* not allowlisted -> not allowed

* small message change

* update test
2022-01-06 09:09:51 -05:00
Andrey Petrov
0eebb64c1d sshd/terminal/terminal.go: Clamp pos to protect from some fuzzing failures 2021-10-13 10:43:49 -04:00
mik2k2
7413539965
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
2021-05-31 10:08:30 -04:00
Andrey Petrov
7a783d46af sshd, chat/message: Add more debug logging for close failures 2021-04-05 11:06:44 -04:00
Andrey Petrov
f113a130ae sshd: Terminal.Term() fallback to Env TERM 2020-04-17 12:22:31 -04:00
Andrey Petrov
adef8d65a2
Merge pull request #342 from shazow/unsafe-password
main: Add --unsafe-passphrase
2020-04-16 12:46:32 -04:00
Andrey Petrov
77143ad1e6 main: Add --unsafe-passphrase 2020-04-15 14:19:28 -04:00
Andrey Petrov
5055bbc859 sshd: Remove temporary "Connecting..." prompt 2020-04-13 11:32:38 -04:00
Andrey Petrov
fdfdcf96b7 main, sshd: Add comments and TODOs 2020-04-12 13:04:53 -04:00
Chris Miller
fe84822f5d Get the term value 2020-04-12 12:37:55 -04:00
Chris Miller
c0a2f32bd4 Wait for shell 2020-04-12 12:37:55 -04:00
Andrey Petrov
5dfa194ec8
Merge pull request #309 from shazow/req-env
sshd: Add Terminal.Env()
2020-04-12 12:36:07 -04:00
Andrey Petrov
5bad08c340 sshd/terminal: gofmt 2020-04-01 20:40:56 -04:00
yumaokao
8c7ea173ad sshd/terminal: Add fullwidth check for CJK in visualLength 2020-03-21 19:57:39 +08:00
Wim
d8f9bc9006 Remove import comment. Fixes #337
Fix issue with go1.13+
See https://github.com/golang/go/issues/37747
2020-03-08 23:32:06 +01:00
Andrey Petrov
6701cbcbf7
sshd: Fix env error check
Co-Authored-By: Chris Miller <millerlogic@users.noreply.github.com>
2020-01-10 09:25:59 -05:00
Andrey Petrov
5af617f3b9
sshd: Apply read deadline to connection handler (#331)
This should prevent connections from stalling out and eating up file descriptors without ever joining the chat.
2020-01-06 20:09:34 -05:00
Akshay Shekher
1b2a3e97a0 sshd/terminal: Add more readline-compatible navigation
- Alt-F: jump forward by a word
- Alt-B: jump backword by a word
- Ctrl-F: jump forward by a character
- Ctrl-B: jump backword by a character
2020-01-05 10:51:10 -05:00
Juan Pablo Ossa Zapata
0a122be81e sshd/terminal: Fix import comment 2019-11-04 11:42:10 -05:00
Andrey Petrov
3e37ebf85a sshd/terminal: Undo emoji offset bugfix
Introduced another bug: #316
2019-04-21 16:48:12 -04:00
Andrey Petrov
5949f9792f sshd: Close connection on failed handshake
Hopefully fixed #315
2019-04-17 16:57:30 -04:00
Andrey Petrov
479a391d55 sshd/terminal: Use clearline and clearscreen codes for enterClear
Fixes emoji offset bug
2019-03-29 17:26:23 -04:00
Andrey Petrov
c9b58a80fa sshd/terminal: Import test from upstream patch 2019-03-29 17:26:23 -04:00
Andrey Petrov
4aa2460d82 sshd: Add Terminal.Env() 2019-03-24 13:41:33 -04:00
Andrey Petrov
87024f3ded sshd/terminal: Clear screen below on enterClear 2019-03-22 15:31:17 -04:00
Andrey Petrov
6acb0bf809 sshchat, host: Switch to new terminal clearline api 2019-03-21 15:33:18 -04:00
Andrey Petrov
b4ba8226c6 sshd/terminal: Switch terminal.ClearLine to termina.SetEnterClear(...) 2019-03-21 15:33:18 -04:00
Andrey Petrov
418c991677 sshd/terminal: Use N-moves in Terminal.move when possible 2019-03-21 15:33:18 -04:00
Andrey Petrov
8b710da728 sshd/terminal: Fix mid-line enter and reflow bugs 2019-03-19 12:09:54 -04:00
Andrey Petrov
4240130978 legal: Put sshd/terminal notice in root 2019-03-18 15:36:21 -04:00
Andrey Petrov
8653f0a730 sshchat: Replace terminal echo hack with our forked terminal 2019-03-18 10:08:39 -04:00
Andrey Petrov
1ba36b785c sshd/terminal: Add Terminal.ClearLine option 2019-03-18 10:08:39 -04:00
Andrey Petrov
596d41ff29 sshd/terminal: Add original LICENSE 2019-03-18 10:08:39 -04:00
Andrey Petrov
aecd8c66c3 sshd/terminal: Import fork of x/crypto/ssh 2019-03-18 10:08:39 -04:00
UlisseMini
9c918676ed sshd: Better comments and changed += 1 to ++ 2019-02-24 09:40:47 -06:00
UlisseMini
e6233daefd sshd: Better comments 2019-02-24 09:40:47 -06:00
Andrey Petrov
903d6c9420
/ban query support (#286)
For #285 

Turns out there were some bugs in Set, and I was using it incorrectly too.

The query syntax is a little awkward but couldn't find a nicer easy to parse format that worked with quoted string values.
2018-12-25 14:29:19 -05:00
Oliver Graff
05597b3e6a Fix unit tests / Travis (#238)
* Fix net_test

* Update host test to add carriage return char

* Fix host_test so it will not hang if the SSH connection fails

Fixes #231, closes #235.
2017-06-14 09:07:24 -04:00
Jesse Shapiro
7781d5b135 sshd: Add SHA256 prefix to pubkey fingerprints (#220)
Fixes #214
2016-10-22 09:49:26 -04:00
Andrey Petrov
3535fb35bb tests: Fix ineffectual assigns 2016-09-01 17:01:47 -04:00
Andrey Petrov
398cd75c5e logging: Add [RemoteAddr] prefix to connection-related messages 2016-08-13 16:22:43 -04:00
Andrey Petrov
c69cefc873 logging: More information about why connections get dropped
Fixes #197 for now, maybe more later.
2016-08-12 16:46:08 -04:00
Dmitri Shuralyov
66adee6f9a /whois: Hide IP if user isn't admin; display client and time joined. (#192)
Resolves #170.
2016-08-06 18:20:34 -04:00
Andrey Petrov
f6de73d420 ratelimiter: Bump up to 16kb/min from 4kb/min 2016-08-06 16:41:19 -04:00
Andrey Petrov
15e14a0872 ratelimit: Increase ratelimit to avoid failing handshakes
Regarding #171
2016-08-03 20:01:07 -04:00
Andrey Petrov
1662ecd431 Fix travisci tests
Bind to localhost rather than all hosts.
2016-08-02 16:03:19 -04:00
Andrey Petrov
2abe368022 style: Fix gofmt and vet complaints 2016-07-31 12:18:06 -04:00
Andrey Petrov
f0db74c874 terminal: Disconnect sooner and more reliably 2016-07-24 22:56:38 -04:00
Andrey Petrov
50d2be3a88 Fixed message buffer timeout 2016-07-24 16:17:02 -04:00
Andrey Petrov
3ba0c59341 Unflake tests, remove lock from chat/message.User 2016-07-24 16:17:02 -04:00