En este pequeño articulo vamos a ver como configurar un servidor ssh para poder acceder remotamente a nuestro server.
Es necesario tener OpenSSH, aunque normalmente se instala de forma predeterminada, incluso si se instaló CentOS Minimal, así que no es necesario instalarlo de nuevo.
Puedes iniciar sesión con la autenticación de contraseña por defecto, pero debes cambiar algunos ajustes de seguridad.
[root@tuserver ~]# nano /etc/ssh/sshd_config # line 48: uncomment and change ( prohibit root login remotely ) PermitRootLogin no # line 77: uncomment PermitEmptyPasswords no PasswordAuthentication yes # Reiniciamos el servicio [root@tuserver ~]# systemctl restart sshd
Si está corriendo el Firewall, debemos concederle permisos… por defecto el puerto 22/TCP (conviene cambiarlo por otro).
[root@tuserver ~]# firewall-cmd --add-service=ssh --permanent success [root@tuserver ~]# firewall-cmd --reload success
Ahora por seguridad cambiamos el puerto por defecto (22) por otro, por ejemplo 3850.
Accedemos con:
nano /etc/ssh/sshd_config
Nos aparecerá algo similar a:
# $OpenBSD: sshd_config,v 1.98 2016/02/17 05:29:04 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/bin:/bin:/usr/sbin:/sbin # 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
Modificamos y descomentamos la linea del puerto:
# $OpenBSD: sshd_config,v 1.98 2016/02/17 05:29:04 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/bin:/bin:/usr/sbin:/sbin # 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 3850 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: # The default requires explicit activation of protocol 1 #Protocol 2
Ahora ya tenemos nuestro server ssh preparado para trabajar.