Skip to content

Instantly share code, notes, and snippets.

@iBet7o
Created January 19, 2015 02:06
Show Gist options
  • Save iBet7o/0f23a35b8b5c8cda057d to your computer and use it in GitHub Desktop.
Save iBet7o/0f23a35b8b5c8cda057d to your computer and use it in GitHub Desktop.
Asegurando ssh en CentOS 6

Cambiar puerto por default

Modificar la variable Port en el archivo sshd_config

#Ejemplo: Port 4568
vim +/Port /etc/ssh/sshd_config

# Reiniciar el servicio ssh
service sshd restart

Abrir el puerto

Agregar la siguiente regla al archivo iptables

vim /etc/sysconfig/iptables

# Agregar la regla
-A INPUT -p tcp -m conntrack --ctstate NEW -m tcp --dport 4568 -j ACCEPT

# Guardar los cambios
iptables -F

# Reiniciar el servicio de iptables
service iptables restart

Bloquear el acceso ssh al usuario root

Modificar la variable PermitRootLogin en el archivo sshd_config

# PermitRootLogin no
vim +/PermitRootLogin /etc/ssh/sshd_config

# Reiniciar el servicio ssh
service sshd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment