Instalación
Vamos a usar OpenSSH por tanto vamos a instalarlo:sudo apt-get install openssh-serverAhora procedemos a su configuración.
Comandos que debemos tener en cuenta
Para editar la configuración del servidor SSH debemos hacer en consola:sudo gedit /etc/ssh/sshd_configPara arrancar el servidor:
sudo /etc/init.d/ssh start* Starting OpenBSD Secure Shell server sshd
Para parar el servidor:
sudo /etc/init.d/ssh stop* Stopping OpenBSD Secure Shell server sshd
Para reiniciar el servidor:
sudo /etc/init.d/ssh restart* Restarting OpenBSD Secure Shell server sshd
Configuración del servidor
Una vez instalado, vamos a configurar el servidor, hacemos en consola:sudo gedit /etc/ssh/sshd_configY podremos editar sus opciones:
# Package generated configuration file
# See the sshd_config(5) manpage for details
# Ponemos el puerto a escuchar por el SSH, por defecto es el 22. Deberemos abrir un puerto en nuestro router redirigiendo hacia la IP interna de la máquina donde lo tengamos.
Port 1234
# Usaremos el protocolo 2 de SSH, mucho más seguro, por tanto forzamos a que siempre conecten por protocolo 2.
Protocol 2
# HostKeys for protocol version 2. El lugar donde se guardan las keys.
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 2048
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication, importante la parte PermitRootLogin
LoginGraceTime 120
PermitRootLogin no
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys
# Don’t read the user’s ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don’t trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#MaxStartups 10:30:60
#Banner /etc/issue.net
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
MaxAuthTries 2
Opciones adicionales de Seguridad
Podemos conectarnos al servidor sin usuario clave, utilizando un certificado RSA que proporcionará mucha más seguridad, pero como siempre que sucede en estos casos…es más incómodo y no siempre vas a llevar encima tu certificado...
Para ver los LOGS de conexión:
cd /var/log/
gedit auth.log
No hay comentarios:
Publicar un comentario