LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 03-31-2006, 02:10 PM   #1
eder_michael11
Member
 
Registered: Jan 2006
Posts: 51

Rep: Reputation: 15
[B]how can i configure SSH to allow only the ip that i want?[/B]


sorry .. do you know .. how can i do it?

i have ip 10.41.0.146 in a lan and i want to accept
that 10.41.0.1 and 10.41.0.2 only connect to my computer by SSH and drop all others

do you know how to do it??

i use .. SLACKWARE 10.0
 
Old 03-31-2006, 02:35 PM   #2
ralvez
Member
 
Registered: Oct 2003
Location: Canada
Distribution: ArchLinux && Slackware 10.1
Posts: 298

Rep: Reputation: 30
You need to use a iptables to filter connections.
If you are new to Linux you may want to sue some thing simple to set up your firewall. One very good and simple firewall is Firestarter.
Take a look here: http://www.fs-security.com/
 
Old 03-31-2006, 03:50 PM   #3
int0x80
Member
 
Registered: Sep 2002
Posts: 310

Rep: Reputation: Disabled
This is off the top of my head, so might need a fix.

Code:
allow="
10.41.0.1 
10.41.0.2
"

iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT

iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
for ip in $allow; do
 iptables -A INPUT -i eth0 -p tcp -s $ip --dport 22 -m state --state NEW -j ACCEPT;
done
 
Old 03-31-2006, 09:03 PM   #4
michaelsanford
Member
 
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468

Rep: Reputation: 30
Or modify sshd to look for hosts.allow, but iptables is a good way to go (because it stops sshd from even hearding abot the connection if it's undesirable). Just offering an alternative
 
Old 04-01-2006, 01:21 AM   #5
eder_michael11
Member
 
Registered: Jan 2006
Posts: 51

Original Poster
Rep: Reputation: 15
modify sshd -,,,,, which part?

thanks to all ... but i was looking for modify sshd ... host.allow

how is the way to do it?
 
Old 04-01-2006, 05:15 PM   #6
michaelsanford
Member
 
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468

Rep: Reputation: 30
Well, `man sshd_config' and `man hosts.allow' are good places to start. They also include warnings...
 
Old 04-02-2006, 07:12 AM   #7
danex50
LQ Newbie
 
Registered: Feb 2004
Location: UK
Posts: 22

Rep: Reputation: 15
Quote:
Originally Posted by eder_michael11
thanks to all ... but i was looking for modify sshd ... host.allow

how is the way to do it?

in hosts.allow there should be something like this:

Code:
sshd: 10.41.0.1 10.41.0.2
and in hosts.deny:

Code:
sshd: ALL
 
Old 04-03-2006, 10:41 AM   #8
eder_michael11
Member
 
Registered: Jan 2006
Posts: 51

Original Poster
Rep: Reputation: 15
ok thnks i will try it
 
Old 04-04-2006, 11:51 AM   #9
eder_michael11
Member
 
Registered: Jan 2006
Posts: 51

Original Poster
Rep: Reputation: 15
doesnt work hosts.allow and hosts.deny

sorry but .. i did that and my computer continues accepting
conexions by ssh from the host that i dont want
i modify hosts.allow like this
sshd: 10.41.0.1 10.41.0.2

and hosts.deny
sshd: ALL

and doesnt work

do i have to modify some thing at sshd_config?

or what is happening?
 
Old 04-04-2006, 12:19 PM   #10
DotHQ
Member
 
Registered: Mar 2006
Location: Ohio, USA
Distribution: Red Hat, Fedora, Knoppix,
Posts: 548

Rep: Reputation: 33
for hosts.deny we use:
All:All

to deny traffic of All kinds. Maybe that'll help.
 
Old 04-05-2006, 10:43 AM   #11
eder_michael11
Member
 
Registered: Jan 2006
Posts: 51

Original Poster
Rep: Reputation: 15
doesnt work at hosts.deny
ALL: ALL

i think that i have to do something more... it seems too easy just puting at

hosts.allow
sshd: 10.41.0.1

hosts.deny
ALL:ALL


i dont know maybe we are missing to modify other file or ... i dont know .. but doesnt work


i found a way editing sshd_config

AllowUsers root@10.41.0.1
DenyUsers ?*?

..............

it seems that works but i would like to do it from the files hosts.allow and deny ....
 
Old 04-05-2006, 06:49 PM   #12
fotoguy
Senior Member
 
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291

Rep: Reputation: 62
The /etc/hosts.deny and /etc/hosts.allow file should work, maybe tcpwrappers is not installed or not install properly.

Last edited by fotoguy; 04-05-2006 at 06:51 PM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to setup rsh or configure ssh properly cheeku Linux - Software 5 03-30-2006 07:47 AM
configure terminal to send keepalives for ssh naijaguy Linux - Newbie 3 03-22-2005 04:40 PM
ssh ./configure problem mrobb Red Hat 1 08-05-2004 02:08 PM
How do I install/configure ssh? Sm1ler Linux - Networking 7 04-16-2004 04:36 AM
How to further configure Ssh? toastermaker Linux - Newbie 10 11-07-2003 03:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration