ubuntuusers.de

SSH Daemon neu starten

Status: Ungelöst | Ubuntu-Version: Server 14.04 (Trusty Tahr)
Antworten |

chricken

Avatar von chricken

Anmeldungsdatum:
29. März 2007

Beiträge: 198

Hallo,

ich habe mal wieder ein Problem. Dieses Mal geht es um den SSH Daemon.

Ich wollte alle Benutzer außer einem von SSH aussperren und habe deswegen die Datei /etc/ssh/sshd_config mit folgenden Zeilen erweitert:

# Eigene Einstellungen
AllowUsers Benutzername
PermitRootLogin no

Das habe ich gespeichert und wollte einer Anleitung entsprechend mittels /etc/init.d/sshd restart den SSH-Daemon neu starten. Aber sshd existiert dort nicht. Ich finde nur /etc/init.d/ssh. Und wenn ich den neu starte ändert sich nicht. Es können sich immer noch alle Benutzer fröhlich per SSH anmelden.

Hat jemand einen Tipp für mich, woran das liegen kann?

Lieben Gruß
Chricken

BillMaier Team-Icon

Supporter

Anmeldungsdatum:
4. Dezember 2008

Beiträge: 6494

Unter Ubuntu ist ssh(d) ein Upstart-Prozess, kein init-Prozess.

Probier deshalb mal

restart ssh

Siehe auch: http://wiki.ubuntuusers.de/SSH#Der-SSH-Server

hoerianer

Anmeldungsdatum:
14. August 2012

Beiträge: 3156

Ich mache das per

'''''sudo service ssh start/stop/restart/status'''''

chricken

(Themenstarter)
Avatar von chricken

Anmeldungsdatum:
29. März 2007

Beiträge: 198

Okay, das hat funktioniert.

Aber: Jetzt antwortet der SSH-Service nicht mehr, wenn sich ein anderer Benutzer als der eingetragene anzumelden versucht.

Also, mein Benutzer kann sich problemlos anmelden. Aber wenn sich ein anderer Benutzer anmelden will, zum Beispiel ein FTP-User, dann antwortet SSH nicht mehr. Irgendwann gibt es dann einen Connection-timeout. Auch ein parallel geöffneter Terminal verweigert ebenfalls den Dienst. Dann hilft nur noch ein Server-Reset, was ich natürlich nur sehr ungern mache.

Ich arbeite übrigens mit Putty von Windows aus. Falls das etwas bedeutet.

Meine sshd_config. Das einzige, was ich eingetragen habe, sind die letzten beiden Zeilen:

# Package generated configuration file
# See the sshd_config(5) manpage for details

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

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

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

# 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

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes

X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

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

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

# EIgene Einstellungen
AllowUsers mein_benutzername
# PermitRootLogin no

Und meine ssh_config, die habe ich meines Wissens unverändert gelassen:

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

Host *
#   ForwardAgent no
#   ForwardX11 no
#   ForwardX11Trusted yes
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   Port 22
#   Protocol 2,1
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
    SendEnv LANG LC_*
    HashKnownHosts no
    GSSAPIAuthentication yes
    GSSAPIDelegateCredentials no

Wenn ich die Zeile AllowUsers wieder auskommentiere, dann funktioniert wieder alles. Leider eben auch die Anmeldung anderer Benutzer.

Hoffentlich hat jemand eine Idee
Chricken

BillMaier Team-Icon

Supporter

Anmeldungsdatum:
4. Dezember 2008

Beiträge: 6494

Mich würde interessieren, wie viele Versuche es braucht, bis die Verweigerung statt findet. Passiert die FTP-User-Anfrage per SSH von der gleichen IP? Ist vielleicht fail2ban aktiv? http://de.wikipedia.org/wiki/Fail2ban

Irgendsowas müsste das sein, anders kann ich mir das nicht erklären.

chricken

(Themenstarter)
Avatar von chricken

Anmeldungsdatum:
29. März 2007

Beiträge: 198

Hallo und vielen Dank für Deine Antwort.

Jetzt wollte ich grad prüfen, ob es an fail2ban lag (es ist tatsächlich aktiviert).

Jetzt passiert etwas anderes: Nach fünf Anmeldeversuchen werde ich mit einer Meldung vom Terminal (Putty) geworfen. Aber dann kann ich erneut versuchen, mich anzumelden. Ohne die eingestellten zehn Minuten zu warten.// Im fail2ban-Log steht unter anderem:

2014-06-10 18:19:55,802 fail2ban.filter : WARNING Determined IP using DNS Lookup: g225234032.adsl.alicedsl.de = ['92.225.234.32']

Wie Ihr Euch sicher schon gedacht habt, ist das meine IP.

Seltsam, muss ich mich wohl nochmal reinknien.

LG Christian

PS: Es ist einfach zu warm zum Denken.

Ripixxx

Anmeldungsdatum:
14. Juni 2010

Beiträge: 67

Hi,

1
2014-06-10 18:19:55,802 fail2ban.filter : WARNING Determined IP using DNS Lookup: g225234032.adsl.alicedsl.de = ['92.225.234.32']

Die Zeile heißt aber nicht das die IP gesperrt wurde. Steht denn Noch eine Zeile dabei?

Was gibt

1
iptables -L

aus

Gruß Joachim

chricken

(Themenstarter)
Avatar von chricken

Anmeldungsdatum:
29. März 2007

Beiträge: 198

Die Zeile heißt aber nicht das die IP gesperrt wurde. Steht denn Noch eine Zeile dabei?

Ja, sehe ich auch so. Aber warum steht sie denn da? Diese Zeile steht übrigens alleine da. Ohne andere, damit zusammenhängende Meldungen.

Der Befehl iptables gibt folgendes aus:

> iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination
fail2ban-postfix-sasl  tcp  --  anywhere             anywhere             multiport dports smtp
fail2ban-dovecot-pop3imap  tcp  --  anywhere             anywhere             multiport dports pop3,pop3s,imap2,imaps
fail2ban-pureftpd  tcp  --  anywhere             anywhere             multiport dports ftp
fail2ban-ssh  tcp  --  anywhere             anywhere             multiport dports ssh
DROP       tcp  --  anywhere             127.0.0.0/8
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
DROP       all  --  base-address.mcast.net/4  anywhere
PUB_IN     all  --  anywhere             anywhere
PUB_IN     all  --  anywhere             anywhere
PUB_IN     all  --  anywhere             anywhere
PUB_IN     all  --  anywhere             anywhere
PUB_IN     all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere

Chain FORWARD (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
DROP       all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
PUB_OUT    all  --  anywhere             anywhere
PUB_OUT    all  --  anywhere             anywhere
PUB_OUT    all  --  anywhere             anywhere
PUB_OUT    all  --  anywhere             anywhere
PUB_OUT    all  --  anywhere             anywhere

Chain INT_IN (0 references)
target     prot opt source               destination
ACCEPT     icmp --  anywhere             anywhere
DROP       all  --  anywhere             anywhere

Chain INT_OUT (0 references)
target     prot opt source               destination
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere

Chain PAROLE (15 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere

Chain PUB_IN (5 references)
target     prot opt source               destination
ACCEPT     icmp --  anywhere             anywhere             icmp destination-unreachable
ACCEPT     icmp --  anywhere             anywhere             icmp echo-reply
ACCEPT     icmp --  anywhere             anywhere             icmp time-exceeded
ACCEPT     icmp --  anywhere             anywhere             icmp echo-request
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:ftp-data
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:ftp
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:ssh
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:smtp
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:domain
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:http
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:pop3
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:imap2
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:https
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:submission
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:imaps
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:pop3s
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:http-alt
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:tproxy
PAROLE     tcp  --  anywhere             anywhere             tcp dpt:webmin
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     udp  --  anywhere             anywhere             udp dpt:mysql
DROP       icmp --  anywhere             anywhere
DROP       all  --  anywhere             anywhere

Chain PUB_OUT (5 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere

Chain fail2ban-dovecot-pop3imap (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-postfix-sasl (1 references)
target     prot opt source               destination
REJECT     all  --  mail.cas.gov.lb      anywhere             reject-with icmp-port-unreachable
REJECT     all  --  i59F61F76.versanet.de  anywhere             reject-with icmp-port-unreachable
RETURN     all  --  anywhere             anywhere

Chain fail2ban-pureftpd (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-ssh (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Ripixxx

Anmeldungsdatum:
14. Juni 2010

Beiträge: 67

Poste mal deinen dazugehörigen Filter.

Antworten |