Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Allow SSH only for some domains
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
sven
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 274

PostPosted: Fri Dec 10, 2004 11:08 am    Post subject: Allow SSH only for some domains Reply with quote

Hi!

Let's say I there are some domains which point to the same server (same IP). On the server there's sshd running. Now I want to allow SSH only for people trying to connect to example1.com but not example2.com or example3.com. Something like the VirtualDomain settings from Apache where I can check the requested domain name.

Is that possible and how would I do that?

Thanks in advance!
Back to top
View user's profile Send private message
robet
l33t
l33t


Joined: 06 Sep 2004
Posts: 807
Location: Earth/NorthAmerica/USA/NY

PostPosted: Fri Dec 10, 2004 12:52 pm    Post subject: Reply with quote

I'm looking for information about this too.
_________________
no software patents in europe! | adopt an unanswered post.
Back to top
View user's profile Send private message
res0nat0r
n00b
n00b


Joined: 07 Jul 2003
Posts: 43
Location: Indiana

PostPosted: Fri Dec 10, 2004 2:05 pm    Post subject: Reply with quote

do you mean that you want to block outbound ssh access to any hosts on the internet except for example1.com?

i am using iptables do do this.

Code:

# iptables -A OUTPUT -p tcp --dport 22 -d \! example1.com -j DROP


i am not sure if this is 100% correct, i dont have my linux box in front of me to test, but i use something similar in reverse for my box at home. i block all inbound access to my home pc's port 22 except for my works ip space which i allow.

something like:

Code:

# iptables -A INPUT -p tcp --dport 22 -s \! xx.0.0.0/8 --syn -j DROP



hope this gets you started.


Last edited by res0nat0r on Fri Dec 10, 2004 2:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
fleed
l33t
l33t


Joined: 28 Aug 2002
Posts: 756
Location: London

PostPosted: Fri Dec 10, 2004 2:10 pm    Post subject: Re: Allow SSH only for some domains Reply with quote

sven wrote:
Hi!

Let's say I there are some domains which point to the same server (same IP). On the server there's sshd running. Now I want to allow SSH only for people trying to connect to example1.com but not example2.com or example3.com. Something like the VirtualDomain settings from Apache where I can check the requested domain name.

Is that possible and how would I do that?

Thanks in advance!


Just like with http+ssl (https) you cannot do it based on domain name only. You have to use something else: different ip or different port for different domains. ssh does not know what domain you're connecting to until the secure connection is done!
Back to top
View user's profile Send private message
hoochiepapa
Tux's lil' helper
Tux's lil' helper


Joined: 02 Oct 2002
Posts: 105

PostPosted: Fri Dec 10, 2004 4:02 pm    Post subject: Reply with quote

if you built openssh to use TCP wrappers;
if not sure run etcat -u openssh look for +tcpd


edit /etc/hosts.allow add something like
sshd: example1.com

and /etc/hosts.deny with
ALL:ALL
Back to top
View user's profile Send private message
fleed
l33t
l33t


Joined: 28 Aug 2002
Posts: 756
Location: London

PostPosted: Fri Dec 10, 2004 5:26 pm    Post subject: Reply with quote

If example1.com and example2.com both point to the same ip address how is tcp wrappers going to be able to distinguish?
Back to top
View user's profile Send private message
hoochiepapa
Tux's lil' helper
Tux's lil' helper


Joined: 02 Oct 2002
Posts: 105

PostPosted: Sat Dec 11, 2004 12:38 am    Post subject: Reply with quote

fleed wrote:
If example1.com and example2.com both point to the same ip address how is tcp wrappers going to be able to distinguish?


Good question.
Only way to find out is to try it.
I don't know of any way to restrict if both names point to a single IP.
Back to top
View user's profile Send private message
Chris W
l33t
l33t


Joined: 25 Jun 2002
Posts: 972
Location: Brisbane, Australia

PostPosted: Sat Dec 11, 2004 4:17 am    Post subject: Reply with quote

The only reason this sort of differentiation between virtual hosts is possible in HTTP is because the client sends the human-friendly host name with the request. Some old HTTP clients do not send the host name with the request and cannot fully use name-based virtual hosts as a result.

The ssh protocol and clients have no accommodation for such a host name transfer and, therefore, from the receiving end there's no way to know which DNS alias was used at the client end.

If you are hoping that this would afford some utility as a security measure then you'd be wasting your time. If I were a black-hat then I'd connect to your IP and forge the "correct" hostname anyway.

TCPWrappers can be used to control where connections are allowed from.
_________________
Cheers,
Chris W
"Common sense: The collection of prejudices acquired by age 18." -- Einstein
Back to top
View user's profile Send private message
sven
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 274

PostPosted: Sun Dec 12, 2004 1:08 pm    Post subject: Reply with quote

Chris W wrote:
The only reason this sort of differentiation between virtual hosts is possible in HTTP is because the client sends the human-friendly host name with the request. Some old HTTP clients do not send the host name with the request and cannot fully use name-based virtual hosts as a result.

The ssh protocol and clients have no accommodation for such a host name transfer and, therefore, from the receiving end there's no way to know which DNS alias was used at the client end.

I thought so.

Chris W wrote:
If you are hoping that this would afford some utility as a security measure then you'd be wasting your time. If I were a black-hat then I'd connect to your IP and forge the "correct" hostname anyway.

TCPWrappers can be used to control where connections are allowed from.

Riiight, but I was just thinking about "security by obscurity". Let's say your domain "myleetdomain.com" is known to everyone but the domain "myserver4632.myisp.com" is only known to you, you would want to disable SSH for "myleetdomain.com" but keep it for the other domain.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum