Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Mar 26, 2013 8:13 am 
Offline
Senior Member

Joined: Tue Aug 14, 2012 5:55 pm
Posts: 82
I am not an expert in linux security but will it be a good practice to allow only my country IP to have SSH and SFTP access ?

If so; how to achieve anything like this ?


Top
   
PostPosted: Tue Mar 26, 2013 8:38 am 
Offline
Senior Member

Joined: Fri Feb 17, 2012 8:20 pm
Posts: 365
It's definitely better than nothing - though the best would be to just allow your own IP. You can do this with iptables. Or you can use CSF Firewall which also has some extra features.


Top
   
PostPosted: Tue Mar 26, 2013 8:53 am 
Offline
Senior Member

Joined: Tue Aug 14, 2012 5:55 pm
Posts: 82
Nuvini wrote:
It's definitely better than nothing - though the best would be to just allow your own IP. You can do this with iptables. Or you can use CSF Firewall which also has some extra features.


Yes but won't work for dynamic IPs.


Top
   
PostPosted: Tue Mar 26, 2013 9:26 am 
Offline
Sysop

Joined: Sat Nov 27, 2010 3:32 am
Posts: 180
Website: https://blog.timheckman.net/
Location: San Francisco, CA
This isn't the recommended way to do things. If you have a dynamic IP address just disable password authentication and use key-based authentication. If for some reason you absolutely need password authentication, use a strong password and limit the ability of people to try and brute force your system by installing something like Fail2Ban.

- http://library.linode.com/security/ssh-keys
- http://library.linode.com/security/fail2ban

Going back to your original inquiry, there isn't a reliable way to do this unfortunately. You could potentially get it down to blocks operated by your country's RIR. In theory these should all be delegated out, and I don't personally see them changing much. But you should have a script that runs periodically to make sure you have the right exceptions in your firewall. You could even go a level lower and only add firewall exceptions for your ISP, but they may get a few more blocks of IP addresses moving forward so you'll need a script to check this. And if you are not connecting via your ISP, you would need to use Lish to add a one-time exception.

I'd recommend the first option...it's served me well so far.

-Tim

_________________
'If debugging is the process of removing bugs, then programming must be the process of putting them in.' //Edsger Dijkstra
'Nothing is withheld from us which we have conceived to do.' | 'Do things that have never been done.' //Russell Kirsch


Top
   
PostPosted: Tue Mar 26, 2013 9:44 am 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 4:11 pm
Posts: 554
Website: http://www.unixtastic.com
Location: Europe
The iptables geoip module allows blocking by country. See http://www.howtoforge.com/xtables-addons-on-centos-6-and-iptables-geoip-filtering. I don't think this works with the standard Linode kernel so you may need to setup your own with pvgrub.

Because you can block by country doesn't make it a good idea. Disable all password authentication and use keypair authentication and you are already as secure as it gets. You can add fail2ban, connection rate limiting in IPtables, or move SSH to a non-standard port but these techniques don't gain you any real security improvements. They will reduce the size of your logfiles though.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group