Google Plus

Make rules sshd to accept ssh from specified IP

Written by Mel Kham on . Posted in Frequently Asked Questions

Question :

How to create an IP TABLES rule which will accept ssh connections only from specified IP`s   ?



Answer :

1- via  Iptables

# Allow incoming ssh only from IP 10.10.1.1
iptables -A INPUT -p tcp -s 10.10.1.1 -d $SERVER_IP --sport 513:65535 --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s $SERVER_IP -d 10.10.1.1--sport 22 --dport 513:65535 -m state --state ESTABLISHED -j ACCEPT

2-Via  /etc/hosts.allow and  hosts.deby

To make this work in hosts.allow|deny…

In /etc/hosts.allow:

Code:

sshd: 127.0.0.1 10.10.1.1

In /etc/hosts.deny:

Code:

sshd: ALL

3- Via  sshd_config

edit  /etc/ssh/sshd_config

Code:

AllowUsers user1@10.10.1.1 user2@ip-address user3......

also you can use

Code:

DenyUsers user@ip-address

For  any  question plese  post it  in The  forum . Thnx

For questions please refer to our Q/A forum at : http://ask.unixmen.com

Mel Kham

Founder of Unixmen, Living in Amsterdam. Am working in my free time to help people to understand the Opensource and to explain them in easy way how to make the fist steps to the the light. Working day and night with my Co-founder Zinovsky to keep this website live even with less resources.

Like us on Facebook

This week Top Posts

Write for us

Recent Comments

DragonFartOutLoud

|

it went to china.

DragonFartOutLoud

|

great review! i’ve been using it as my main OS since Beta 1 release. its been a awesome ride so far :)

jet li

|

i try the method, and i unzip the image contain zip secret, i dont find the file that i was hide, where it go? and how to open it? :s

zinovsky

|

Yes, it is possible using Steganography, we will post another quick howto do that in the next few days

SK

|

Hey Abhishek

Yes there are many open source tools available to meet your requirements. They are easy to manage and has a decent web gui to configure. We will publish all of them one by one shortly. Stay tuned with us.

 
IDG Tech Network
Copyright © 2008-2013 Unixmen.com .
Maintained by Anblik .