Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-20-2006, 12:31 AM
|
#1
|
Member
Registered: Feb 2005
Location: ~h3av3n~
Distribution: RHEL 4, Fedora Core 3,6,7 Centos 5, Ubuntu 7.04
Posts: 227
Rep:
|
Ban IP's of certain countries
Everyday i get huge log file of some idiots trying to use random SSH username/password login on my server & probably a DoS attack. I have clients located in US who SFTP to my srever to download files.
I have setup SSH the following way:
1) chrooted SFTP login only
2) Allow authorized users only with " ALlowUsers" keyword in /etc/ssh/sshd_config
3) No root login
4) Protocol 2 only
5) Listen on 0.0.0.0
I only have to allow connection from outside to my SSH port 22 in my iptables other all other NEW connections are DROP in my firewall.
How do stop this. change port 22 to another port?
here is part of my log. Most of the source IP's are from China:
Quote:
Failed password for invalid user telnetd from 61.129.64.93 port 43254 ssh2
Invalid user telnetd from 61.129.64.93
error: Could not get shadow information for NOUSER
Failed password for invalid user telnetd from 61.129.64.93 port 43271 ssh2
Invalid user toor from 61.129.64.93
error: Could not get shadow information for NOUSER
Failed password for invalid user toor from 61.129.64.93 port 43293 ssh2
Invalid user toor from 61.129.64.93
error: Could not get shadow information for NOUSER
Failed password for invalid user toor from 61.129.64.93 port 43317 ssh2
Invalid user toor from 61.129.64.93
error: Could not get shadow information for NOUSER
Failed password for invalid user toor from 61.129.64.93 port 43338 ssh2
Invalid user toor from 61.129.64.93
error: Could not get shadow information for NOUSER
Failed password for invalid user toor from 61.129.64.93 port 43363 ssh2
Invalid user toor from 61.129.64.93
error: Could not get shadow information for NOUSER
Failed password for invalid user toor from 61.129.64.93 port 43380 ssh2
Invalid user toor from 61.129.64.93
error: Could not get shadow information for NOUSER
Failed password for invalid user toor from 61.129.64.93 port 43402 ssh2
Invalid user toor from 61.129.64.93
error: Could not get shadow information for NOUSER
Failed password for invalid user toor from 61.129.64.93 port 43429 ssh2
error: Could not get shadow information for NOUSER
Failed password for invalid user username from 69.59.170.124 port 35292 ssh2
Invalid user user from 69.59.170.124
error: Could not get shadow information for NOUSER
Failed password for invalid user user from 69.59.170.124 port 35881 ssh2
User root not allowed because not listed in AllowUsers
error: Could not get shadow information for NOUSER
Failed password for invalid user root from 69.59.170.124 port 36382 ssh2
Invalid user admin from 69.59.170.124
error: Could not get shadow information for NOUSER
Failed password for invalid user admin from 69.59.170.124 port 36958 ssh2
User test not allowed because not listed in AllowUsers
error: Could not get shadow information for NOUSER
Failed password for invalid user test from 69.59.170.124 port 37467 ssh2
.
.
.
|
Last edited by ~=gr3p=~; 01-20-2006 at 12:34 AM.
|
|
|
01-20-2006, 04:38 AM
|
#2
|
Newbie
Registered: Oct 2003
Location: South Africa
Distribution: Redhat, Fedora, Ubuntu
Posts: 27
Rep:
|
Unfortunately the world is full of idiots.... just watch the news every day....
The best that you can do is monitor and start blocking the culprit IPs
Also read up on rate limiting... check a site like http://www.debian-administration.org/articles/187 ....
Good luck
|
|
|
01-20-2006, 04:50 AM
|
#3
|
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141
Rep: 
|
Will your legitimate clients agree to using keys to login with instead of username/passwords? That's how we're set up here. All username/password attempts fail, only users who've got their public key in ~/.ssh on the ssh server can get in.
|
|
|
01-20-2006, 05:29 PM
|
#4
|
Member
Registered: May 2004
Distribution: FreeBSD 7, Debian "Squeeze", OpenBSD 4.5
Posts: 167
Rep:
|
|
|
|
01-20-2006, 06:14 PM
|
#5
|
Member
Registered: May 2004
Posts: 123
Rep:
|
Quote:
Originally Posted by gilead
Will your legitimate clients agree to using keys to login with instead of username/passwords? That's how we're set up here. All username/password attempts fail, only users who've got their public key in ~/.ssh on the ssh server can get in.
|
I just setup my own server in this way and I'm very happy with it! I finally feel at least somewhat safe running SSH. I also moved the service to an obscure port.
|
|
|
01-20-2006, 06:35 PM
|
#6
|
Senior Member
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291
Rep:
|
You can also look at setting up some rules through iptables to limit the amount of new connections to the port you are now running on if you have the `recent` module built into the kernel. just type at the prompt:
modprobe ipt_recent
If you don't get an error, you have the module installed, you can start limiting the amount of connections in a certain time period before blocking. The `recent` module creates a list and adds ip-addresses to the list, after the time limit specified has expired the ip-address can connect again. some example rules would look like this:
# $IPTABLES -A INPUT -p tcp -i eth0 --dport 22 -m state --state NEW -m recent --name sshprobe --set -j ACCEPT
# $IPTABLES -A INPUT -p tcp -i eth0 --dport 22 -m state --state NEW -m recent --name sshprobe --update --seconds 60 --hitcount 3 -j DENY
|
|
|
01-20-2006, 11:41 PM
|
#7
|
Member
Registered: Feb 2005
Location: ~h3av3n~
Distribution: RHEL 4, Fedora Core 3,6,7 Centos 5, Ubuntu 7.04
Posts: 227
Original Poster
Rep:
|
hey kool learned nice tricks here  thnks. currently i have changed my port to someting else now i will try above tricks
|
|
|
01-21-2006, 06:45 AM
|
#8
|
Member
Registered: Mar 2005
Distribution: FC4
Posts: 83
Rep:
|
|
|
|
01-21-2006, 09:00 PM
|
#9
|
Member
Registered: Feb 2005
Location: ~h3av3n~
Distribution: RHEL 4, Fedora Core 3,6,7 Centos 5, Ubuntu 7.04
Posts: 227
Original Poster
Rep:
|
this site rox n linux rox
amazing knowledge thnxa ton
|
|
|
01-22-2006, 05:02 PM
|
#10
|
Senior Member
Registered: Aug 2004
Location: Munich, Germany
Distribution: Opensuse 11.2
Posts: 1,549
Rep:
|
You can change ssh to another port quite easily and it does stop the attacks but a better solution would be something like http://denyhosts.sourceforge.net/
|
|
|
01-23-2006, 05:07 AM
|
#11
|
Member
Registered: Feb 2005
Location: ~h3av3n~
Distribution: RHEL 4, Fedora Core 3,6,7 Centos 5, Ubuntu 7.04
Posts: 227
Original Poster
Rep:
|
^^ thats an excellent utility thnx
|
|
|
01-24-2006, 02:28 PM
|
#12
|
Member
Registered: May 2004
Location: Atlanta, GA USA
Distribution: Redhat ES4, FC4, FC5, slax, ubuntu, knoppix
Posts: 155
Rep:
|
Something to consider also, the log indicates a few ip addresses. Thes attackers are most likely using an automated brute force program. A way to defeat it is to listen on a different port than 22. I changed my defaul SSH port to another lesser known port and the attacks you're seeing have gone away.
The programs that scan are wanting to get the "low hanging fruit" so to speak. They are going after defaults and looking for ssh v1 etc.. By changing the port you can save yourself the headache of the idiots.
G'luck
|
|
|
All times are GMT -5. The time now is 08:56 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|