* Imagenes de instalación de las versiones estables para Mageia y OpenMandriva.

OpenMandriva: Mageia (Mageia 9) 20/Agosto/2023 - Anuncio, Descargas.

Blogdrake recomienda descargar las imágenes de instalación (iso) vía torrent para evitar corrupción de datos, aprovechar mejor su ancho de banda y mejorar la difusión de las distribuciones.

2.2. Evitar intentos de conexión a SSH con host.deny y consejos para dotarlo de mayor seguridad

Gracias a la nueva funcionalidad del cortafuegos de Mandriva, me doy cuenta que alguien se está intentando conectar por ssh (concreta mente, desde echo1007.ncsrv.de) a mi PC de sobremesa (que actúa también como servidor de almacenamiento, entre otras cosas). Pues bien, lo que hice para poder seguir conectándome desde el portátil al servidor a ssh, fue lo siguiente. 1. Editamos el archivo /etc/hosts.allow y lo dejamos así (poniendo las ips que queramos que se conecten al servicio):

sshd: XXX.XXX.XXX.XX1
sshd: XXX.XXX.XXX.XX2
sshd: XXX.XXX.XXX.XX3
...

2. Luego, editamos el archivos /etc/hosts.deny y lo dejamos tal que así:

sshd: ALL

Después de ésto, sólo las ips que hayamos puesto en hosts.allow podrán conectarse a éste servicio, impidiéndole el sistema cualquier acceso a éste puerto a cualquier otra ip.

Opciones de visualización de comentarios

Seleccione la forma que desee de mostrar los comentarios y haga clic en «Guardar opciones» para activar los cambios.


Gravatar de bart_bender

# 51184 Muy limitado

Bueno lo que comentas está muy bien si solo conectas desde 3 direcciones fijas pero cuando utilizas el servidor habitualmente no es la mejor solución (o requiere un mantenimiento excesivo habilitando y deshabilitando IPs)

Otra solución mas abierta pero bastante segura es.

-Quitar el acceso a root (es el usuario mas habitual con el que intentan conectar, siempre puedes poner el comando su si lo necesitas una vez abierta la sesión)
Para ello o bien lo configuras en drakconf (ccm) , servicios de red , configuración del demonio SSH, configuración avanzada, Permitir conexión de root (no)
O bien editas el fichero /etc/ssh/denyusers agregando en una linea la palabra root

-Limitar el número de reintentos de login (por ejemplo 5 o 6) y poniendo un retardo de tiempo para evitar posibles ataques de fuerza bruta.

-Limitar los usuarios que tienen acceso de modo estricto.

-crear una key cifrada en un dispositivo usb para acceder...

SSH dota de una funcionalidad muy extensa, merece la pena leer la documentación (reenvío de las X, ssh tunneling, etc)

Un ejemplo de fichero de configuración podría ser este


# $OpenBSD: sshd_config,v 1.75 2007/03/19 01:01:29 djm Exp $

# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/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 change a
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2
HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 4m
#PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6

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

# For this to work you will also need host keys in /etc/ssh/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

#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#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 /var/run/sshd.pid
MaxStartups 16
PermitTunnel no

# no default banner path
Banner /etc/ssh/banner.txt

# override default of no subsystems
Subsystem sftp /usr/lib64/ssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server
Port 22
ListenAddress 0.0.0.0
SyslogFacility AUTH
LogLevel VERBOSE
AllowUsers xxx,yyyy,zzz
LoginGraceTime 300
KeepAlive yes
RSAAuthentication no
PubkeyAuthentication no
AuthorizedKeysFile .ssh/authorized_keys2
PasswordAuthentication yes
IgnoreRhosts yes
PermitEmptyPasswords no
Compression yes
StrictModes yes
PrintMotd yes
PrintLastLog yes
MaxAuthTries 6

Echale un ojo cuando te aburras...
JyJGames
ZonaCocinillas



Gravatar de motitos

# 51199 Cambia el numero del puerto

Suele ser una medida muy sencilla y bastante efectiva, porque los ataques por fuerza bruta se suelen centrar en el puerto 22.

Para cambiar el puerto, en /etc/ssh/sshd_config busca la linea

Port 22

y pon otro numero, digamos

Port 59999

O el que se te ocurra. Cuando te quieras conectar, tienes que usar el comando

ssh -p 59999 usuario@maquina

MOT

MOT



Gravatar de DoctorBOFH

# 51201 Bueno

Pues entre todos habeis escrito un excelente howto sobre seguridad en ssh.Merece la pena guardarlo.

Gracias

Bravas,el DoctorBofh

«No entiendes realmente algo a menos que seas capaz de explicárselo a tu abuela». Albert Einstein

Muy Suyo

Her DoctorBOFH



Gravatar de Annubis

# 51254 Muchas gracias a todos

La verdad, mi "solución" era un poco de andar por casa y rápida. El único uso que le doy a ssh es para controlar el servidor desde el portátil, y sólo desde mi casa. Vuestras aportaciones han sido fantásticas jeje. Da gusto ver la colaboración en ésta comunidad.

Gracias y un saludo



Gravatar de Annubis

# 59595 Un añadido.

Leyendo mis RSS, me encuentro con éste artículo de Kriptópolis (¿lo leo demasiado últimamente? xD), que habla sobre DenyHosts, un script hecho en Python, que detecta actividad anormal desde un mismo host, intentando conectarse a nuestro servicio ssh, lo añade a nuestro /etc/hosts.deny, para impedir que siga "atacando".

Creí recomendable comentar ésto, ya que blindará aún más nuestro sistema.

Opciones de visualización de comentarios

Seleccione la forma que desee de mostrar los comentarios y haga clic en «Guardar opciones» para activar los cambios.