Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux HostsFree MagazinesJobs
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Linux Security
Reload this Page interested about country restriction
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Linux Security Discussion about keeping your machines secure, and the crackers out.

Reply
 
Thread Tools Display Modes
Old 02-23-2008   #1 (permalink)
Just Joined!
 
Join Date: Feb 2008
Posts: 6
interested about country restriction

I'm really interested about country restriction, because my ISP doesn't provide static IP and I need to have access to my VPS via ssh, but these days f*****ng crackers seem to attack my box many and many times with brute force attack.

Could someone get me more info and a howto about country restriction?

Thanks all!

_YD
paperogiallo is offline   Reply With Quote
Old 02-23-2008   #2 (permalink)
Linux Newbie
 
Join Date: Feb 2006
Location: Jyväskylä, Finland
Posts: 101
Well, I think the most effective solution to this problem could be to start filtering SSH login attempts. sshdfilter or fail2ban are in my opinion quite good tools to cut overwhelming amount of failed ssh logins. They scan syslog for such attempts and place a strict ban on IP address after certain number of failed tries. In that way you hadn't to suffer from loss of usability (you still could use your box from foreign TLDs and other domains) and any inappropriate breakin attempts.

You could also move your sshd to listen to another port, like 222 or 2222 or such, it probably would quite effectively stop any random attempts. But it definitely will not stop the attacks if the crackers have decided to try to get into your box. In such case probably they just scan your host once more and notice you have done such trick - and continue like nothing was happened.

Speaking of tcp wrappers, you have two files residing in /etc. They're called hosts.allow and hosts.deny. As said before, tcp wrappers restricts access just by filtering incoming connections by IP address and FQDN. In case you decide to pass further with tcp wrappers this page should help. Of course, consult also man.
__________________
Computers can never replace human stupidity.
kavalakala is offline   Reply With Quote
Old 02-23-2008   #3 (permalink)
Just Joined!
 
Join Date: Feb 2008
Posts: 6
Many thanks, also for quickness!

I've changed ssh and webmin default ports yet.

I can't read man pages on my system because I have only ssh access to it (it's a Virtual Private Server hosted by a provider in a webfarm), and I've got only Windows-based computers at home.
I'm sure I can find a lot of useful information in linked pages, anyway. I think fail2ban is what I need!

BTW, I've just installed rootkit hunter on my system, and found 2 rootkit installed.

Another question, if I could: is it normal that rootkit hunter find 2 version of ssh? Into the log file I have two rows for:
ssh 3.9p1 [OK]
ssh [unknown - no version found]
First one is in /usr/sbin, second one in /usr/local/sbin ... how can I check which one is "in use"?

Again, many thanks!

_YD
paperogiallo is offline   Reply With Quote
Old 02-24-2008   #4 (permalink)
Linux Enthusiast
 
Lazydog's Avatar
 
Join Date: Jun 2004
Location: Pennsylvania
Posts: 515
The best way to thaw brutforce attacks is to use keys and move the port.

They can attach all day and never get in.

No password needed and you could carry your key on a usb stick for when
you use diferent machines.

Check out this SSH Link
It is a good way to use ssh keys.
__________________

Regards
Robert

It is not just an adventure.
It is my job!!

Linux User #296285
Get Counted
Lazydog is offline   Reply With Quote
Old 02-24-2008   #5 (permalink)
Just Joined!
 
Join Date: Feb 2008
Posts: 6
Thanks for good advice, I will take a look.

Another question: ssh is not logging any activity at all! On my system (Centos), it should use /var/log/secure for logging (according with syslog.conf, it has standard "authpriv.* /var/log/secure"), but nothing goes on that file... I also tried to explicitly force it to log writing "LogLevel: INFO" in sshd_config, but nothing changes...

How could I turn ssh logging on? This is crucial to use fail2ban or similar!

_YD
paperogiallo is offline   Reply With Quote
Old 02-24-2008   #6 (permalink)
Just Joined!
 
Join Date: Feb 2008
Posts: 6
Ok, failed sshd login attempts are logged in /var/log/messages, not in /var/log/secure... doh...

I installed fail2ban, configuring it to work with hosts.deny and hosts.allow. I tried a fake connection via ssh, mispelling my password five times. A correct rule is now written in hosts.deny (ALL: my_ip), but I can still have access via ssh. Why? Do I have to tell ssh to use hosts.deny, maybe?

I'm sorry if my questions seem to be silly to someone...

_YD
paperogiallo is offline   Reply With Quote
Old 02-24-2008   #7 (permalink)
Linux Enthusiast
 
Lazydog's Avatar
 
Join Date: Jun 2004
Location: Pennsylvania
Posts: 515
Hmmm.......

If I'm not mistaking, and it has be known to happen from time to time, host.allow is checked before host.deny is. So if you have anything written in there for your host to allow ssh then that might be why you still have access.
__________________

Regards
Robert

It is not just an adventure.
It is my job!!

Linux User #296285
Get Counted
Lazydog is offline   Reply With Quote
Old 02-24-2008   #8 (permalink)
Just Joined!
 
Join Date: Feb 2008
Posts: 6
Thanks, but hosts.allow is void...

(I love your State... eated a very good soup near ... hmmm... the city famous for the battle! I'm Italian, so I don't know about anything about American history... sorry...)

_YD
paperogiallo is offline   Reply With Quote
Old 02-26-2008   #9 (permalink)
Linux Newbie
 
Join Date: Feb 2006
Location: Jyväskylä, Finland
Posts: 101
If I understood right, you made a rule to fail2ban which mangles hosts.allow and hosts.deny? In my opinion a more effective way would be to use fail2ban with iptables: failed attempt involves just a basic shell command which applies the rule which bans all incoming port 22 connections from specific host - when preferred time has passed, fail2ban just runs another command which removes the ban from iptables.

Of course you can use tcp wrappers for additional security (you once configure hosts.allow and hosts.deny to suit your needs) but IMHO continuous mangling of such config files via automated scripts is very clumsy.

There are also some cons when using a system such as fail2ban. It requires constant logging and log-watching and in that way consumes the resources of server. A bigger disadvantage or even a security breach would be the chance of Denial of Service. For example if there are users from a big NAT'd subnet (such as municipalities's and schools's intranets), it would be quite easy to perform a DoS attack. The attacker needs just to gain access to one workstation residing in the victim network and perform some false logins to fail2ban running server. The whole subnet would be unable to login to that server because every connection behind the NAT would appear as coming from one single host - which got banned.

Lazydog suggested implementing the key based authentication which prevents such risks but naturally, if the crackers are allowed to hammer your server, it increases the bandwidth usage
__________________
Computers can never replace human stupidity.
kavalakala is offline   Reply With Quote
Old 02-26-2008   #10 (permalink)
Just Joined!
 
Join Date: Feb 2008
Posts: 6
I've read somewhere that IPTables are not configured on many Virtual Private Server, so I choose tcpwrappers... but, is there a way to check if iptables are installed on my system?

_YD
paperogiallo is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
 

Similar Threads
Thread Thread Starter Forum Replies Last Post
Foriegn country IP's adrenaline Servers 2 04-05-2007 05:31 AM
restriction using squid(proxy) pankajkarde11 Servers 1 03-17-2007 03:28 PM
Any Artists Interested? deek Art & Imaging in Linux 18 08-18-2006 12:15 PM
Interested in Tinkering w/ LinuxPPC64? jones010 Linux Newbie 0 02-16-2006 09:42 PM
Where is your favourite country? AndrewB The Coffee Lounge 37 01-31-2005 09:33 AM

Free Magazines
Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe
Systems Management News, the newspaper for IT systems administration and data center managers!
Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe
The Enterprise Newsweekly
eWeek is the essential technology information source for builders of e-business.
subscribe
Oracle Magazine
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe
Total Telecom
Total Telecom is "The Economist of the communications industry".
subscribe
More free magazines »



All times are GMT. The time now is 10:33 PM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.2.0