analytics

viernes, 12 de abril de 2013

Autenticación en dos pasos en SSH usando Google-authenticator

Ahora que los servicios en la nube estas proporcionado más seguridad a través de doble autenticación, vamos a llevar esto a nuestro entorno SSH. Esto lo llevaré a cabo con CentOS 6.4, pero lo podréis exportar a vuestras distribuciones Linux. En vuestro teléfono móvil deberéis tener instalado Google AutenticatorBarcode Scanner.

Instalamos git, las librerías de pam y herramientas para compilar:
# yum install git pam-devel make gcc-c++
Descargamos el código
# git clone https://code.google.com/p/google-authenticator/
# cd google-authenticator/libpam
Compilar e instalar
# make
# make install
Ahora vamos a modificar la configuración pam del servicio SSH:
# vi /etc/pam.d/sshd
Añadir esto en la primer linea:
auth       required     pam_google_authenticator.so
Configuración del servicio SSH
# vi /etc/ssh/sshd_config
Cambiar:
ChallengeResponseAuthentication no
Por:
ChallengeResponseAuthentication yes
Ahora podremos reiniciar SSH
#service sshd restart
Lanzamos la instalación

# google-authenticator
Do you want authentication tokens to be time-based (y/n) y
https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/root@centos%3Fsecret%3NG24L2ZJ37DKINBC
Your new secret key is: NG24L2ZJ37DKINBC
Your verification code is 782169
Your emergency scratch codes are:
  54423068
  76239020
  91147133
  97108204
  17509634

Do you want me to update your "/root/.google_authenticator" file (y/n) y

Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) y

By default, tokens are good for 30 seconds and in order to compensate for
possible time-skew between the client and the server, we allow an extra
token before and after the current time. If you experience problems with poor
time synchronization, you can increase the window from its default
size of 1:30min to about 4min. Do you want to do so (y/n) y

If the computer that you are logging into isn't hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting (y/n) y

Deberéis entrar en el link que os adjudica la instalación y ver el código con el Barcode Scanner, automáticamente se os abrira google authenticator
Aceptamos y listo:
Ahora antes de conectar por SSH a la maquina os pedara el código de verificación:
# ssh root@centos
Verification code:
Password:
 Fuente: linuxdrops.com

No hay comentarios:

Publicar un comentario