public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Mick <michaelkintzios@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] IPtables question
Date: Wed, 31 Jan 2007 23:25:38 +0000	[thread overview]
Message-ID: <200701312325.49328.michaelkintzios@gmail.com> (raw)
In-Reply-To: <1170276978.31556.3.camel@blackwidow.nbk>

[-- Attachment #1: Type: text/plain, Size: 2422 bytes --]

On Wednesday 31 January 2007 20:56, Albert Hopkins wrote:
> On Wed, 2007-01-31 at 15:36 -0500, James Colby wrote:
> > List members -
> >
> > I have a small home server that I have connected to the internet
> > through a linksys router and cable modem.  The linksys router is
> > currently forwarding all ssh traffic to my gentoo box.  What I would
> > like to do is set up iptables to only allow ssh logins from a small
> > number of internet hosts, and to reject and log all other ssh
> > attempts.  Can someone please help me out with this.  All of the
> > tutorials and documentation that I have found are setting up a fully
> > functioning firewall / NAT / proxy, and I think that is a little
> > overkill for my needs.s
>
> If you don't want the whole iptables suite you might want to consider
> good ole hosts.allow/hosts.deny as an alternative.  They work fine with
> sshd if you have tcpwrappers enabled.

It depends how secure you want your set up to be.  I always suggest to disable 
passwd authentication and enable public key authentication, after you copy & 
paste each client's public key in the file ~/.ssh/authorized_keys.  Any 
passwd cracking attacks will simply fail.  I would also suggest that you move 
your sshd port from 22 to a higher number.  All/most of these bots scanning 
port 22 will now leave you alone.  Finally, you can set up additional layers 
like allow/deny users, MAC addresses, etc.  While you're at it, don't forget 
disabling root logins.

If you want to introduce diverse protection then iptables (and as previously 
suggested hosts.allow/hosts.deny) is an option.  In your iptables script (or 
saved set of iptables rules) add something like:

iptables -A INPUT -i eth0 -p tcp -s <client_ip_address> -m tcp --dport 22 -d 
<server_LAN_ip_address> -j ACCEPT

Of course, I suggest that you change port 22 in the line above to a higher 
number 'free' port.  Your final catch-all rule at the bottom of your iptables 
will drop any packets (on any port) from hosts other than the clients you 
specified in my line above.

Finally, you can repeat this in your router's firewall rules, assuming that 
you can specify WAN ip addresses (I know that you can in my hardware router, 
but don't know in yours).

If any one manages to break in to the server through such a sshd setup, then 
they bl**dy well deserve it!

HTH.
-- 
Regards,
Mick

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2007-01-31 23:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-31 20:36 [gentoo-user] IPtables question James Colby
2007-01-31 20:56 ` Albert Hopkins
2007-01-31 23:25   ` Mick [this message]
2007-02-01  3:58 ` Norberto Bensa
2007-02-02  8:45 ` Pawel Kraszewski
2007-02-02  9:54   ` Hans-Werner Hilse
2007-02-02 11:01     ` Pawel Kraszewski
  -- strict thread matches above, loose matches on Subject: below --
2011-12-16 15:17 [gentoo-user] iptables question Tanstaafl
2011-12-17 16:34 ` Hari Purnama
2011-12-17 17:25   ` Tanstaafl
2006-03-28 13:38 Hiren Dave
2006-03-28 14:06 ` Boyd Stephen Smith Jr.
2006-03-28 14:35 ` Uwe Thiem
2006-03-29  2:24 ` JimD
2006-01-20 19:49 Dmitry S. Makovey
2006-01-20 20:49 ` Trenton Adams
2006-01-20 22:21   ` Dmitry S. Makovey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200701312325.49328.michaelkintzios@gmail.com \
    --to=michaelkintzios@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox