PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : SSH geht nicht durch den Paketfilter



bla!zilla
29.05.03, 16:22
Hi Leute.

Ich hab da ein merkwürdiges Problem: Ich hab hier auf meinem Router einen Apache laufen. Paketfilterung und Masquerading übernimmt Iptables. Läuft auch alles wunderbar. Der Apache ist auch von außen erreichbar. Zudem läuft für die Administration ein SSH. Den wollte ich nun auch von außen zugänglich machen. Entsprechende Rule existiert im Iptables Skript. Ein Portscan sagt auch das alle Ports, bis auf 80 und 22, blocked sind. Nur ich komme nich via Putty drauf! Apache geht, SSH nicht. Warum? Irgendwelche Ideen? Zumal der Scanner meint das der Port offen wäre?

Folgendes finde ich zum besagten Zeitpunkt in der /var/log/auto.log

May 28 08:37:02 tripwire sshd[30377]: refused connect from 212.xxx.xxx.xxx
May 28 08:37:45 tripwire sshd[30378]: refused connect from 212.xxx.xxx.xxx

Die IP ist mir bekannt, das war ich selber vom Büro aus (ist die externe IP der Firewall) :D . Auf andere Rechner kann ich über diese Firewall zugreifen per SSH.

1000 Dank.

Olli
29.05.03, 16:35
Poste mal die entsprechenden iptables-Regeln....

bla!zilla
29.05.03, 16:44
Original geschrieben von Olli
Poste mal die entsprechenden iptables-Regeln....

Das komplette Skript gibt es hier:

http://tripwire.justdied.com/tmp/firewall.txt

Der Gestreifte
29.05.03, 18:12
Wird der Verbindungsaufbau möglicherweise durch Einträge in den Dateien "/etc/hosts.{allow,deny}" verweigert?

bla!zilla
29.05.03, 18:16
Hab ich mir auch schon gedacht, aber waren die Dateien nicht nur für Dienste relevant die via (x)inetd gestartet werden? Mein SSHd läuft aber als Deamon. Egal...

Hier meine /etc/hosts.allow



# /etc/hosts.allow: list of hosts that are allowed to access the system.
# See the manual pages hosts_access(5), hosts_options(5)
# and /usr/doc/netbase/portmapper.txt.gz
#
# Example: ALL: LOCAL @some_netgroup
# ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
#
# If you're going to protect the portmapper use the name "portmap" for the
# daemon name. Remember that you can only use the keyword "ALL" and IP
# addresses (NOT host or domain names) for the portmapper. See portmap(8)
# and /usr/doc/portmap/portmapper.txt.gz for further information.
#

ALL: 192.168.20.


Hier meine /etc/hosts.deny



# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system.
# See the manual pages hosts_access(5), hosts_options(5)
# and /usr/doc/netbase/portmapper.txt.gz
#
# Example: ALL: some.host.name, .some.domain
# ALL EXCEPT in.fingerd: other.host.name, .other.domain
#
# If you're going to protect the portmapper use the name "portmap" for the
# daemon name. Remember that you can only use the keyword "ALL" and IP
# addresses (NOT host or domain names) for the portmapper. See portmap(8)
# and /usr/doc/portmap/portmapper.txt.gz for further information.
#
# The PARANOID wildcard matches any host whose name does not match its
# address. You may wish to enable this to ensure any programs that don't
# validate looked up hostnames still leave understandable logs. In past
# versions of Debian this has been the default.
# ALL: PARANOID

ALL: ALL

McG.linux
29.05.03, 18:41
vielleicht ein Versionsprob (ssh2/ssh1)?

Gruß
mcg.linux

Berufspenner
29.05.03, 18:47
Hi@all

Sollte es in der hosts.allow nicht vieleicht
ALL: 192.168.20.0 heißen? Ist nur so eine Idee.

Cu
André

bla!zilla
29.05.03, 22:38
@ McG.linux

Versionsproblem kann ich defintiv ausschließen. Der SSHd nimmt nur v2 Verbindungen an, und genau das habe ich auch im PuTTY eingerichtet.

@ Berufspenner

Da es sich um ein Netz handelt, kann die abschließende 0 weggelassen werden.

@ All

Es ist ja nicht so das die Pakete rausgefiltert werden. Die Verbindung wird ja abgelehnt (siehe Eintrag in /var/log/auth.log). Frage ist nur: Warum? IMHO entweder hosts.deny/allow oder SSH Config.

Berufspenner
29.05.03, 22:43
Hi@all

@blazilla
Ja, grade weil es ein Netz ist. Ich weis ja nicht wie weit, wie das gehandelt wird, aber ein IPv4 Adresse sollte diese Syntax haben: xyz.xyz.xyz.xyz Hatl je nachdem um was für ein Klassennetz es sich handelt.

Cu
André

bla!zilla
30.05.03, 08:08
Das ist mir schon klar. Normalerweise müsste man auch noch eine Subnetmask mit angeben bzw. auf CIRD zurückgreifen. Aber es geht hier um den Syntax der /etc/hosts.allow/deny. Und da ist es erlaubt die letzte 0 wegzulassen.

PigPen|tuX
30.05.03, 08:58
huhu,

dann wird es die Konfiguration des SSH-Servers sein



## Host restrictions

# AllowHosts localhost, foobar.com, friendly.org
#
## Next one matches with, for example, taulu.foobar.com, tuoli.com, but
## not tuoli1.com. Note that you have to input string "\." when you want it
## to match only a literal dot. You also have to escape "," when you
## want to use it in the pattern, because otherwise it is considered a list
## separator.
##
## AllowHosts t..l.\..*
##
## The following matches any numerical IP-address (yes, it is cumbersome)
##
## AllowHosts ([[:digit:]]{1\,3}\.){3}[[:digit:]]{1\,3}
##
## Same thing is achieved with using the special prefix "\i" in a
## pattern. This means that the pattern is only used to match
## IP-addresses.
##
## Using the above example:
##
## AllowHosts \i.*
##
## You can probably see the difference between the two.
##
## Also, you can use subnet masks, by using prefix "\m"
##
## AllowHosts \m127.0/8
## and
## AllowHosts \m127.0.0.0/24
##
## would match localhost ("127.0.0.1").
##
# DenyHosts evil\.org, aol\.com
# AllowSHosts trusted\.host\.org
# DenySHosts not\.quite\.trusted\.org
# IgnoreRhosts no
# IgnoreRootRHosts no
# (the above, if not set, is defaulted to the value of IgnoreRHosts)

## User restrictions

AllowUsers testuser.*,
DenyUsers root.*,
# DenyUsers don@untrusted\.org
# AllowGroups users
DenyGroups guest,anonymous
PermitRootLogin no
# PermitRootLogin nopwd
################################################## #######################
# AllowUsers sj.*,s[[:digit:]]*,s(jl|amza)
# DenyUsers skuuppa,warezdude,31373
# DenyUsers don@untrusted\.org
# AllowGroups staff,users
# DenyGroups guest,anonymous
# PermitRootLogin no
# PermitRootLogin nopwd
################################################## ########################

## Chrooted environment

# ChRootUsers anonymous,ftp,guest
# ChRootGroups sftp,guest

## SSH1 compatibility

Ssh1Compatibility no
# Sshd1Path <set by configure by default>
#
# This is given as argument to sshd1 with "-f" if sshd2 is invoked
# with "-f", otherwise the default configuration for sshd1 is used.
# Sshd1ConfigFile /etc/sshd_config_alternate




schaue dir mal deine sshd2.config an, ;)

see you
thom

bla!zilla
30.05.03, 12:18
Schaun' mer mal. IMHO ist die sauber.



# Package generated configuration file
# See the sshd(8) manpage for defails

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# ...but breaks Pam auth via kbdint, so we have to turn it off
# Use PAM authentication via keyboard-interactive so PAM modules can
# properly interface with the user (off due to PrivSep)
PAMAuthenticationViaKbdInt no
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 60
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# rhosts authentication should not be used
RhostsAuthentication no
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Uncomment to disable s/key passwords
#ChallengeResponseAuthentication no

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes


# To change Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#AFSTokenPassing no
#KerberosTicketCleanup no

# Kerberos TGT Passing does only work with the AFS kaserver
#KerberosTgtPassing yes

X11Forwarding no
X11DisplayOffset 10
PrintMotd no
#PrintLastLog no

KeepAlive no
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net
#ReverseMappingCheck yes

Subsystem sftp /usr/lib/sftp-server
IgnoreUserKnownHosts no
ReverseMappingCheck no
GatewayPorts no
AllowTcpForwarding yes
AllowGroups sshusers


Ich bekomme ja schon keinen Connect zum SSHd.