
SSH Zugang aus dem Internet absichern am Beispiel der LS Kirkwood- Serie
Da mein NAS noch Zusatzaufgaben erledigen muss, ist es sehr angenehm, es auch aus der Ferne per SSH steuern zu können.
Natürlich versuchen Hacker sofort auf diese offene Schnittstelle zuzugreifen.
Das belastet das System aber nur sehr gering, so lange es nicht tausende Angreifer sind.
Vermerk werden die Versuche in der /var/log/messages
Code:
Dec 18 09:28:54 DUO3 auth.info sshd[16930]: Failed password for root from 103.41.124.35 port 39128 ssh2
Dec 18 09:28:54 DUO3 auth.info sshd[16930]: Failed password for root from 103.41.124.35 port 39128 ssh2
Dec 18 09:28:55 DUO3 auth.info sshd[16930]: Failed password for root from 103.41.124.35 port 39128 ssh2
Lösungen um den Server sicherer zu machen:
1) den Port 22 nicht am Router Port 22 freigeben Es wird ein hoher ungewöhnlicher Port empfohlen z.B. 43256
2) neue Nutzer anlegen, welche sich die Administratorrechte verschaffen dürfen und dann den root aussperren
Voraussetzung Optware ist installiert nach:
http://forum.nas-hilfe.de/buffalo-technology-nas-anleitungen/ssh-freischalten-auf-einer-DUO3-t2165.html
ssh aktualiseren und anpassen
Ich habe es mit dem ab Werk vorinstallierten sshd version OpenSSH_3.7.1p2 nicht geschafft, also installiere ich den neuen ssh.
Weitere Ziele:
1) neuen Nutzern den Zugriff per ssh gestatten
2) diesen Nutzern das Wechseln zum root gestatten
3) dem root den ssh- Zugang verbieten
Aktualisieren von ssh
Code:
ipkg install openssh
Erfolgsmeldung:
Zitat:
Installing openssh (5.9p1-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable/openssh_5.9p1-1_arm.ipk
Das neue Startscript deaktivieren
Code:
chmod 666 /opt/etc/init.d/S40sshd
den neuen ssh im alten Skript eintragen
Code:
sed -i 's/SSHD=\/usr\/local\/sbin\/sshd/SSHD=\/opt\/sbin\/sshd/g' /etc/init.d/sshd.sh
neuen Nutzer anlegen:
neue Gruppe anlegen
sudo installieren:
Nutzer hinzufügen, die den Befehl sudo ausführen dürfen:
Code:
echo "Poweruser ALL=(ALL) ALL">>/opt/etc/sudoers
Später
wollen wir mit dem Befehl sudo su - dem Poweruser zum root machen. Dazu
muss auch der Befehl su vom Poweruser ausfühbar sein. Hierzu muss er
der Gruppe wheel angehören.
Den Poweruser in die Gruppe wheel eintragen
Code:
usermod -a -G wheel Poweruser
Um eine Fehlermeldung
Zitat:
su: Module is unknown
zu umgehen, müssen wir noch ein Modul abschalten.
Code:
sed
-i 's/session.*required.*pam_env.so/#session
required pam_env.so/g' /etc/pam.d/su
3) den root aussperren4) Testauf einer Pro Duo läuft es, auf einer LS-VL nicht
Verdacht usepam no habe ich auf Verdacht gesetzt.
hier die Files der Duo
root@DUO3:~# cat /etc/sshd_config
AllowUsers root andre
Das ist wohl durch einen Tippfehler passiert > anstatt >>
Also ist diese Datei wohl nicht mehr wichtig für den neuen ssh unter opt
Code:
root@DUO3:~# cat /opt/etc/openssh/sshd_config
# $OpenBSD: sshd_config,v 1.84 2011/05/23 03:30:07 djm Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/opt/sbin:/opt/bin:/usr/sbin:/usr/bin:/sbin:/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
# The default requires explicit activation of protocol 1
#Protocol 2
# HostKey for protocol version 1
#HostKey /opt/etc/openssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /opt/etc/openssh/ssh_host_rsa_key
#HostKey /opt/etc/openssh/ssh_host_dsa_key
#HostKey /opt/etc/openssh/ssh_host_ecdsa_key
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024
# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
# For this to work you will also need host keys in /opt/etc/openssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
# 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 no
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /opt/var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none
# no default banner path
#Banner none
# override default of no subsystems
Subsystem sftp /opt/libexec/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server
AllowGroups wheel
Danke an:
http://forum.buffalo.nas-central.org/viewtopic.php?f=69&t=17016