1 |
On Monday 5 June 2006 17:06, Leandro Melo de Sales wrote: |
2 |
> Hi, |
3 |
> |
4 |
> today when I was checking the server log I got many external |
5 |
> attempts to connect to my sshd service: |
6 |
> |
7 |
> ... |
8 |
> Jun 5 05:09:45 embedded sshd[4740]: Invalid user barbara from x.y.w.z |
9 |
> Jun 5 05:09:46 embedded sshd[4742]: Invalid user barb from x.y.w.z |
10 |
> Jun 5 05:09:48 embedded sshd[4744]: Invalid user barbie from x.y.w.z |
11 |
> Jun 5 05:09:50 embedded sshd[4746]: Invalid user barbra from x.y.w.z |
12 |
> Jun 5 05:09:51 embedded sshd[4748]: Invalid user barman from x.y.w.z |
13 |
> Jun 5 05:09:53 embedded sshd[4750]: Invalid user barney from x.y.w.z |
14 |
> ... |
15 |
> |
16 |
> this seems to be a brute force attack, but one thing that worried me |
17 |
> is why sshd didn't disconnect the remote host after 3 unsuccessful |
18 |
> attemps? If we see in the log, there are many attemps with time |
19 |
> interval between attemps of 2 or 3 seconds meaning that the sshd |
20 |
> didn't disconnect the remote host after 3 attempts. |
21 |
|
22 |
AFAIK, sshd disconnects when 3 incorrect passwords are tried _for the |
23 |
same account_. |
24 |
|
25 |
> So, first, Am I thinking correct about the sshd attempts? |
26 |
> Second, how can I setup sshd or the entire system to permit just 2 or |
27 |
> 3 attempts of authentication? I was checking the /etc/login.defs file |
28 |
> and I see the following option: |
29 |
> |
30 |
> # |
31 |
> # Max number of login retries if password is bad |
32 |
> # |
33 |
> LOGIN_RETRIES 3 |
34 |
> |
35 |
> but why this didn't work for the above connection attempts? |
36 |
|
37 |
See above. |
38 |
|
39 |
At the very least, you should not permit root login from ssh and choose |
40 |
very strong passwords for the users that are allowed to login or |
41 |
(better) set up public key authentication, although that is not very |
42 |
practical if the same users may log in from random hosts. In this case, |
43 |
one-time passwords could be useful (google for opie or otpw). |
44 |
|
45 |
After that, there are many things you can (and should) do. Some examples |
46 |
include: changing the port on which the ssh daemon listens (not a very |
47 |
effective solution though), using port knocking, using iptables to limit |
48 |
the attemps to no more than two or three per minute, use one of the many |
49 |
denyhosts/fail2ban/captcha modules out there, and so on. Google is your |
50 |
friend here. |
51 |
|
52 |
HTH |
53 |
-- |
54 |
gentoo-user@g.o mailing list |