Limit linux server SSH connections from outside

Dear experts,

I found out that our mail server can be access from outside via ssh.

It does not know what is from outside and inside basically. A huge problem for me.

I need an idea on how to stop its outside access and keep only from LAN.

I take I need to begin IPTable work.. Anything else?

The Server is in a DMZ.

Thank you!
marceloNYCMiddle-Tier AdministratorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ncomperCommented:
Afternoon,
   Good article is available here:

http://askubuntu.com/questions/115940/how-can-i-setup-ssh-so-that-it-is-restricted-to-my-local-network

This shows you the IP tables and also has information on setting up access with Keys rather than having password protected accounts
0
Jan SpringerCommented:
Specifically, which distribution and which version?

You should also be running fail2ban with ssh connections.
1
marceloNYCMiddle-Tier AdministratorAuthor Commented:
more /etc/*-release
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"
0
What were the top attacks of Q1 2018?

The Threat Lab team analyzes data from WatchGuard’s Firebox Feed, internal and partner threat intelligence, and a research honeynet, to provide insightful analysis about the top threats on the Internet. Check out our Q1 2018 report for smart, practical security advice today!

1ly4meCommented:
some basic things to consider,

First read about DMZ,

Limit from your firewall if you have one. (find your mail server IP and block it there to outside.)
Disable password login (also root login) on your ssh server and enable public key auth,
(create strong public/private key pair with password.)
1
Jan SpringerCommented:
Let's get a list of rules first so that we can insert:

iptables --list -n --line-numbers

Please make a list of all tcp and udp ports that need to be accessed and by what address.  If you only want examples instead of a complete set of rules, we can do that also.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
marceloNYCMiddle-Tier AdministratorAuthor Commented:
Some samples will be great.

Thank you!
0
Jan SpringerCommented:
That's no problem.

I need to know your input chain (you'll get that from an "iptables --list -n").

In CentOS land, it would look like this:

iptables -I INPUT 5 -s 192.168.1.0/24 -p tcp -m tcp --dport 22 -j ACCEPT

This will insert this into line 5 of your iptables rules allowing the subnet 192.168.1.0/24 ssh to the server on any interface.

Either only allow ssh by IP/subnet or install fail2ban.  I do both and both work well.

The important data point with these rules is that either iptables isn't running or you have the usual allow all to ssh.  So just inserting this rule without considering further rules could be problematic.
1
marceloNYCMiddle-Tier AdministratorAuthor Commented:
I like CentOS more but here they are all Debian and want nothing else... :(
0
Jan SpringerCommented:
I guess what I'm saying is that the default input chain is called "INPUT".

If you do an "iptables --list -n", we can get the accurate chain name.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Security

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.