ssh Zugriffsbeschränkung IP-Adressen...

Backup, Restore und Transfer von Daten
Post Reply
cyber_bushi
Posts: 35
Joined: 2002-09-13 17:10
 

ssh Zugriffsbeschränkung IP-Adressen...

Post by cyber_bushi »

Kann ich ssh so beschränken, dass es Verbindungen nur mit bestimmten IP-Adressen aufbaut? Also nicht, dass ssh nur an einer bestimmten ip-adresse lauscht, sondern dass ich nur eine verbindung aufbauen kann, wenn ich am client eine ip-adresse habe, die mit 217 beginnt.
Ich will so rein ssh "beschneiden", nicht andere services.
jtb
Posts: 599
Joined: 2002-08-18 16:41
Location: Darmstadt
Contact:
 

Re: ssh Zugriffsbeschränkung IP-Adressen...

Post by jtb »

siehe http://www.openbsd.org/cgi-bin/man.cgi? ... SD+Current
ListenAddress
Specifies the local addresses sshd should listen on. The follow-
ing forms may be used:

ListenAddress host|IPv4_addr|IPv6_addr
ListenAddress host|IPv4_addr:port
ListenAddress [host|IPv6_addr]:port

If port is not specified, sshd will listen on the address and all
prior Port options specified. The default is to listen on all lo-
cal addresses. Multiple ListenAddress options are permitted. Ad-
ditionally, any Port options must precede this option for non
port qualified addresses.

ein partial matching wirst du wohl kaum hinbekommen..
dodolin
Posts: 3840
Joined: 2003-01-21 01:59
Location: Sinsheim/Karlsruhe
Contact:
 

Re: ssh Zugriffsbeschränkung IP-Adressen...

Post by dodolin »

@Jtb: Ich glaube, du hast cyber_bushi falsch verstanden.

Direkt mit einer Option in der sshd_config geht das nicht. Auf meinem Debian woody ist der sshd allerdings standardmässig so eingestellt, dass er tcp_wrapper benutzt, d.h. du kannst in /etc/hosts.allow sowas reinschreiben:

sshd: 192.168.1.0/255.255.255.0 192.168.10.0/255.255.255.0 127.0.0.1/255.0.0.0

und gleichzeitig in /etc/hosts.deny folgendes:

# Deny everything. This way we must list allowed things in hosts.allow
ALL: ALL

Ansonsten könntest du das natürlich noch über einen lokalen Paketfilter wie z.B. iptables lösen.
rootmaster
Posts: 483
Joined: 2002-04-28 13:30
Location: Hannover
 

Re: ssh Zugriffsbeschränkung IP-Adressen...

Post by rootmaster »

dodolin wrote:Direkt mit einer Option in der sshd_config geht das nicht. Auf meinem Debian woody ist der sshd allerdings standardmässig so eingestellt, dass er tcp_wrapper benutzt, d.h. du kannst in /etc/hosts.allow sowas reinschreiben:

sshd: 192.168.1.0/255.255.255.0 192.168.10.0/255.255.255.0 127.0.0.1/255.0.0.0

und gleichzeitig in /etc/hosts.deny folgendes:

# Deny everything. This way we must list allowed things in hosts.allow
ALL: ALL

Ansonsten könntest du das natürlich noch über einen lokalen Paketfilter wie z.B. iptables lösen.
eine weitere möglichkeit, die ohne tcp_wrapper und sogar auf user-basis funzt, soll nicht verschwiegen bleiben ;) -> pam

in /etc/pam.d/sshd hinzufügen

Code: Select all

account  required       pam_access.so
dann in /etc/security/access.conf

Code: Select all

-:userx:ALL EXCEPT 217.
userx kannst du durch "ALL" oder auch durch zb "ALL EXCEPT userxy" (um userxy von anders woher zu erlauben) ersetzen !

"back to the roots"
Cahn's Axiom:

When all else fails, read the instructions
dodolin
Posts: 3840
Joined: 2003-01-21 01:59
Location: Sinsheim/Karlsruhe
Contact:
 

Re: ssh Zugriffsbeschränkung IP-Adressen...

Post by dodolin »

eine weitere möglichkeit, die ohne tcp_wrapper und sogar auf user-basis funzt, soll nicht verschwiegen bleiben -> pam
Coole Sache! Wenn wir schon dabei sind, alle Möglichkeiten zu sammeln, dann sollte man IMHO auch noch diese hier erwähnen:

aus man sshd:
AUTHORIZED_KEYS FILE FORMAT
$HOME/.ssh/authorized_keys is the default file that lists the public keys
that are permitted for RSA authentication in protocol version 1 and for
public key authentication (PubkeyAuthentication) in protocol version 2.
AuthorizedKeysFile may be used to specify an alternative file.

[...]

from="pattern-list"
Specifies that in addition to RSA authentication, the canonical
name of the remote host must be present in the comma-separated
list of patterns (`*' and `'? serve as wildcards). The list may
also contain patterns negated by prefixing them with `'!; if the
canonical host name matches a negated pattern, the key is not
accepted. The purpose of this option is to optionally increase
security: RSA authentication by itself does not trust the network
or name servers or anything (but the key); however, if somebody
somehow steals the key, the key permits an intruder to log in
from anywhere in the world. This additional option makes using a
stolen key more difficult (name servers and/or routers would have
to be compromised in addition to just the key).
Hatte ich vorhin schon gefunden, es aber nicht erwähnt, weil es
a) nur pro User geht und
b) nur bei PubKey-Authentication geht, nicht bei Password-Authentication.

IMHO trotzdem eine gute Möglichkeit...
Post Reply