lunes, 7 de enero de 2013

Agilizar login SSH en algunas distros

En algunas distros por "default" existen algunas configuraciones en nuestro sistema que no usamos, y estas solo alentan los procesos que cotidianamente hacemos.

para ver que es lo que hace el ssh cuando tarda casi un minuto "pensando" tratándose de conectar, podemos conectarnos usando el modo verbose  "-v"  esto nos muestra realmente que está haciendo en cada momento y de ahí podemos determinar que eslo que está alentando el login a nuestros servidores.

villatux@sitco:~$ ssh -v root@midominio.com.mx
OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to midominio.com.mx [189.220.182.XXX] port 22.
debug1: Connection established.
debug1: identity file /home/villatux/.ssh/id_rsa type -1
debug1: identity file /home/villatux/.ssh/id_rsa-cert type -1
debug1: identity file /home/villatux/.ssh/id_dsa type -1
debug1: identity file /home/villatux/.ssh/id_dsa-cert type -1
debug1: identity file /home/villatux/.ssh/id_ecdsa type -1
debug1: identity file /home/villatux/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-7ubuntu1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024 br="br" sent="sent">debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 0b:3f:d4:5a:38:ce:90:9b:4c:3e:aa:e1:b5:fe:21:70
debug1: Host 'villatux.com.mx' is known and matches the RSA host key.
debug1: Found key in /home/villatux/.ssh/known_hosts:36
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found

debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Next authentication method: publickey
debug1: Trying private key: /home/villatux/.ssh/id_rsa
debug1: Trying private key: /home/villatux/.ssh/id_dsa
debug1: Trying private key: /home/villatux/.ssh/id_ecdsa
debug1: Next authentication method: password
root@midominio.com.mx's password:


En la salida anterior vemos que esta tratando de conectarse con autenticación kerberos:

debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found


Si no tenemos un servidor kerberos disponible va a hacer el maximo de intentos para lograr la conexión ,  y como no tenemos un servidor kerberos, pues solo desabilitamos esa opción en nuestro  /etc/ssh/ssh_config de esta manera:

Donde dice:
GSSAPIAuthentication yes
Lo cambié por:
GSSAPIAuthentication no

Y ahora el ssh se conecta inmediatamente, como siempre debió haber sido.