[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anteriorRevisión previa
Próxima revisión
Revisión previa
es:howtos:security:ssh [2019/03/18 01:50 (UTC)] – [Improving OpenSSH security] antares_alfes:howtos:security:ssh [2019/03/24 20:37 (UTC)] (actual) – [Sources] antares_alf
Línea 10: Línea 10:
 Necesitará saber cómo usar un editor de texto para poder seguir este HOWTO. Si eres un principiante completo, prueba ''nano''.Una vez que esté más avanzado y más cómodo con Linux, siéntase libre de usar algo más poderoso ... Necesitará saber cómo usar un editor de texto para poder seguir este HOWTO. Si eres un principiante completo, prueba ''nano''.Una vez que esté más avanzado y más cómodo con Linux, siéntase libre de usar algo más poderoso ...
  
-===== The SSH configuration files and finding more information =====+===== Los archivos de configuración de SSH y encontrar más información =====
  
-The [[http://www.openssh.org|OpenSSH]] configuration files reside in the directory ''/etc/ssh/''The most important one is the ''/etc/ssh/sshd_config'' that we are going to modify here.+Los archivos de configuración de [[http://www.openssh.org|OpenSSH]] residen en el directorio''/etc/ssh/''El más importante es el ''/etc/ssh/sshd_config'' que vamos a modificar aquí.
  
-The [[http://www.openssh.org|OpenSSH]] documentation is very goodso feel free to enter the command: ''apropos openssh'' or ''man -k openssh'' and read the different man pageswhich are much more detailed than this wiki page.+La documentación de [[http://www.openssh.org|OpenSSH]] es muy buenaasí que siéntase libre de ingresar el comando: ''apropos openssh'' or ''man -k openssh'' y lea las diferentes páginas man, que son mucho más detalladas que esta página wiki. 
 +===== Modificando el archivo sshd_config =====
  
-===== Modifying the sshd_config file =====+La primera regla, antes de modificar un archivo de configuración importante es hacer una copia de respaldo. Por ejemplo:
  
 +<code>
 +# cp -v /etc/ssh/sshd_config /etc/ssh/sshd_config.ORIG.20120826
 +</code>
  
-The first rulebefore you modify an important configuration file is to make backup copy of itFor instance:+El comando mostrado arriba hace una copia del archivo ''sshd_config'' y añadir la extención ''.ORIG'' (por original, por supuesto)e incluir la fecha de modificación. Aunque no es perfectoeste sistema asegurar que siempre pueda volver la versión previa del importante archivo ingresando el siguiente código.
  
-''# cp -v /etc/ssh/sshd_config /etc/ssh/sshd_config.ORIG.20120826''+<code> 
 +# cp -v /etc/ssh/sshd_config.ORIG.20120826 /etc/ssh/sshd_config 
 +</code>
  
-The command shown above will make a copy of the ''sshd_config'' fileand append the extension ''.ORIG'' (for originalof course) and include modification date. While not perfectthis system insures that you can always go back to the previous version of an important file by entering the following:+Tenga en cuenta que esta es una sugerenciapor supuestoy se recomienda encarecidamente los administradores de sistemas que tienen que administrar grandes instalacionescon cientos de servidores, investigar mejores soluciones, como [[http://puppetlabs.com/|Puppet]] u otros gestores de configuración de sistemas distribuidos.
  
-''# cp -v /etc/ssh/sshd_config.ORIG.20120826 /etc/ssh/sshd_config''+Ahora, edite el archivo ''/etc/ssh/sshd_config'' con su editor favorito y ajusta las siguientes lineas:
  
-Please note that this is suggestionof courseand system administrators that have to manage large installationwith hundreds of serversare strongly advised to investigate better solutions, such as [[http://puppetlabs.com/|Puppet]] or other distributed system configuration managers.+===== Cambiar el puerto predeterminado de SSH ===== 
 +Por defecto, OpenSSH escucha en el puerto ''22''. A veces se recomienda cambiar este puerto predeterminado algo diferentecomo ''2222'' o ''4242''. Esto no es una mala ideapero debe recordar que al escanear su máquina con un programa como ''nmap'' obtendrá este nuevo puerto muy rápidamente.Por lo tantosi bien puede ralentizar algunos ataques en su máquinano los evitará por completo.
  
-Nowedit the ''/etc/ssh/sshd_config'' file with your favourite editor and tweak the following lines:+Si desea cambiar el puertobusque la opción ''Port'' en ''sshd_config'', que generalmente está en la parte superior del archivo, y cambie el valor.
  
-===== Change the SSH default port ===== +Por ejemplo:
- +
-By default, OpenSSH listens on port 22. It is sometimes advised to change this default port to something different, such as ''2222'' or ''4242''. This is not a bad idea, but you have to remember that scanning your machine with a program such as ''nmap'' will obtain this new port very quickly. So, while it may slow down some attacks on your machine, it will not prevent them entirely. +
- +
-If you'd like to change the port, search for the ''Port'' option in ''sshd_config'', which is usually at the top of file, and change the value. +
- +
-For instance:+
  
 ''Port 22'' ''Port 22''
  
-Can be changed to:+Puede cambiarse por:
  
 ''Port 4242'' ''Port 4242''
 +===== Método alternativo para cambiar el puerto predeterminado de SSH sin cambiarlo =====
  
 +Esta sugerencia es completamente sacada de otro sitio. [[http://null.redcodenetwork.ro/changing-the-ssh-port-without-changing-it/|redcodenetwork.ro]]
 +La idea aquí es agregar una llamada a este script en ''rc.local'' para que se ejecute al inicio.\\ Para usar el ejemplo de descarga en la parte inferior, cámbielo a su gusto y guárdelo en ''/etc/rc.d/'' (haga que sea ejecutable)\\ Agregue este ejemplo a continuación a ''/etc/rc.d/rc.local''.
 +<code>
 +if [ -x /etc/rc.d/rc.ssh_hide ]; then
 + /etc/rc.d/rc.ssh_hide
 +fi
 +</code>
  
-===== Alternate method of Changing the SSH default port without changing  ===== + Lo que está haciendo es hacer que parezca que ha cambiado el puerto que está usando ssh y proporcionar cierta seguridad adicional
- +Lo que sucede es que los escáneres continuarán viendo el puerto 22 abierto e intentarán ir allí mientras su servidor deja caer esos paquetesporque el encabezado no está dañadoLos paquetes reales vienen en el puerto 8889 y son redirigidos por iptables al puerto 22 con mangle en el encabezado para que no se caigan.
-This suggestion is completely lifted from another site [[http://null.redcodenetwork.ro/changing-the-ssh-port-without-changing-it/]] +
- The idea here is add a call to this script in rc.local so it will run at start up+
- +
-To use Download sample at the bottom change as you like and save it in /etc/rc.d/  (make it executable to use) +
-Add this sample below to /etc/rc.d/rc.local +
- +
-#add ssh_hide to port 8889 +
-  if [ -x /etc/rc.d/rc.ssh_hide ]; then +
-    /etc/rc.d/rc.ssh_hide +
-  fi +
-   +
- What it is doing is making it look like you changed the port ssh is using and provide some additional security. +
-What happens is scanners will continue to see port 22 open and try to go there while your server drops those packetsbecause the header is not mangled Real packets come in on port 8889 and are redirected by iptables to port 22 with mangle in the header so they don't get dropped.+
  
 <file bash rc.ssh_hide> <file bash rc.ssh_hide>
Línea 94: Línea 90:
 </file> </file>
  
-Note not ipv6 compatible, due to nat (ip6tables not supporting nat)+Tenga en cuenta que no es compatible con ipv6debido a nat (ip6tables no son compatibles con nat)
  
 +===== Prohibir el acceso root a su máquina =====
  
-===== Forbid root access to your machine ===== +Este es probablemente el cambio más importante que puede hacer para mejorar la seguridad de su máquinaprohibir que el usuario ''root'' acceda a su máquinaPara hacer estobusque la siguiente línea en ''sshd_config'':
- +
- +
-This is probably the single most important change you can do to improve the security of your machineforbid the ''root'' user to access your machineTo do thislook for the following line in ''sshd_config'':+
  
 ''PermitRootLogin yes'' ''PermitRootLogin yes''
  
-And change it to:+Y cambiarlo a:
  
 ''PermitRootLogin no'' ''PermitRootLogin no''
  
-If you apply the changes abovemake sure you have at least one user on your machine that can ''su'' (switch user) to ''root'' or use ''sudo'' for more fine-grained system administration permissionsThe best way to administrate server through SSH is to have a user in the ''wheel'' groupwho can use both ''sudo'' and ''su'' to become ''root'' when need be.+Si aplica los cambios anterioresasegúrese de tener al menos un usuario en su máquina que pueda  (cambiar de usuario) ''su'' ''root'' use ''sudo'' para permisos de administración del sistema más específicos La mejor manera de administrar un servidor través de SSH es tener un usuario en el grupo ''wheel'', que puede usar ''sudo'' ''su'' para convertirse en ''root'' cuando sea necesario.
  
-Since most people who try to get into your machine uninvited use brute-force scripts that target the ''root'' loginyou can already rest a lot easierknowing this access is locked.+Ya que la mayoría de las personas que intentan ingresar a su máquina sin ser invitadas usan scripts de fuerza bruta que apuntan al inicio de sesión 'raíz', ya puede descansar mucho más fácilmentesabiendo que este acceso está bloqueado.
  
-===== Improve login security and timing =====+===== Mejorar la seguridad de inicio de sesión y el tiempo =====
  
 +Arriba y debajo de la opción ''PermitRootLogin'', encontrará otros permisos, que detallaremos rápidamente aquí:
  
-Above and below the ''PermitRootLogin'' option, you will find other permissions, that we are going to detail quickly here: +- ''LoginGraceTime''se utiliza para aumentaro disminuirel tiempo que le queda un usuario para iniciar sesión en la máquinaEsto se puede restringir de forma segura a minutoscon lo siguiente:
- +
-- ''LoginGraceTime'' is used to increaseor decreasethe time left to user to log into the machineThis can be safely be restricted to minuteswith the following:+
  
 ''LoginGraceTime 5m'' ''LoginGraceTime 5m''
  
-- ''MaxAuthTries'' is used to increseor decreasethe number of tries allowed to user to authentify correctly to the machineThis can be restricted to attempts by using:+- ''MaxAuthTries'' se utiliza para aumentaro disminuirel número de intentos permitidos un usuario para autenticar correctamente en la máquinaEsto se puede restringir a intentos usando:
  
 ''MaxAuthTries 3'' ''MaxAuthTries 3''
  
-===== Deny X11 forwarding =====+===== Denegar reenvío X11 =====
  
- +A menos que necesite usar X11 sobre SSH, puede desactivarlo de manera segura usando la siguiente opción:
-Unless you need to use X11 over SSH, you can safely disable it by using the following option:+
  
 ''X11Forwarding no'' ''X11Forwarding no''
  
-Please note that disabling X11 does not disable VNC over SSH, for instanceIn most casesit is always a good idea to disable un-needed services.+Tenga en cuenta que deshabilitar X11 no deshabilita VNC a través de SSH, por ejemploEn la mayoría de los casossiempre es una buena idea deshabilitar los servicios innecesarios.
  
-===== Restrict SSH login to approved users =====+===== Restringir el inicio de sesión SSH a usuarios aprobados =====
  
- +Si está seguro de que solo usuarios específicos necesitan conectarse a través de SSH a su máquinapuede declararlos usando la opción ''Permitir usuarios''Todos los usuarios, y solo los usuarios, mencionados después de la opción podrán conectarse a través de SSH a la máquina.
-If you are sure only specific users need to connect through SSH to your machineyou can declare them using the ''AllowUsers'' optionAll the users - and only the users - mentioned after the option will be able to connect through SSH to the machine.+
  
 ''AllowUsers jack backup betty'' ''AllowUsers jack backup betty''
  
-In the example shown aboveonly user ''jack'', ''betty'' and ''backup'' will be able to use SSH to connect to the machineAll other users will be denied accessOf courseyou should use this option with caution and make sure the (or "a"default user is included...+En el ejemplo que se muestra arribasolo el usuario ''jack'', ''betty'' ''backup'' podrá usar SSH para conectarse a la máquinaA todos los demás usuarios se les negará el accesoPor supuestodebe usar esta opción con precaución y asegurarse de que el usuario predeterminado ("a"esté incluido ...
  
-===== Restart the SSH server ===== 
  
 +===== Reinicie el servidor SSH =====
  
-The last thing to doto make sure the SSH server takes the new configuration into accountis to restart the SSH server with the command:+Lo último que debe hacerpara asegurarse de que el servidor SSH tenga en cuenta la nueva configuraciónes reiniciar el servidor SSH con el comando:
  
 ''# /etc/rc.d/rc.sshd restart'' ''# /etc/rc.d/rc.sshd restart''
  
-Your new, and slightly more secure OpenSSH configuration is now in effectCongratulations! +Su nueva y más segura configuración de OpenSSH será efectiva ahora¡Felicidades
- +===== Ver también =====
-===== See Also =====+
  
  
-  * [[http://openssh.org/manual.html|OpenSSH manual pages (on-line)]]+  * [[http://openssh.org/manual.html|Páginas de manual de OpenSSH (en línea)]]
  
 ====== Sources ====== ====== Sources ======
Línea 161: Línea 151:
 <!-- * Original source: [[http://some.website.org/some/page.html]] --> <!-- * Original source: [[http://some.website.org/some/page.html]] -->
 <!-- Authors are allowed to give credit to themselves! --> <!-- Authors are allowed to give credit to themselves! -->
-  * Originally written by [[wiki:user:noryungi | User Noryungi]]+  * Escrito originalmente por [[wiki:user:noryungi | User Noryungi]] 
 +  * Traducido al español por  --- //[[wiki:user:antares_alf|Antares_alf]] 2019/03/24 20:32 (UTC)//
 <!-- * Contrbutions by [[wiki:user:yyy | User Y]] --> <!-- * Contrbutions by [[wiki:user:yyy | User Y]] -->
  
 es:howtos:security:ssh ()