Banner

7/07/2010

Cómo loguearnos por ssh sin poner la contraseña?

Mediante ssh-keygen creamos la llave publica y la privada, ssh-copy-id copia la llave publica del host local hacia el fichero .ssh/authorized_key del host remoto, aplicando además los permisos apropiados:

#1: Crear la llave publica y la privada mediante ssh-key-gen en el host local:

3caram@local-host$ [Nota: estamos en el host local]
3caram@local-host$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/3caram/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/3caram/.ssh/id_rsa.
Your public key has been saved in /home/3caram/.ssh/id_rsa.pub.
The key fingerprint is:
33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 3caram@local-host

# 2: Copial la llave pública hacia el host remoto utilizando ssh-copy-id:


3caram@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub usuario_host_remoto@ip_host_remoto
usuario_host_remoto@ip_host_remoto's password:
Now try logging into the machine, with "ssh 'remote-host'", and check in:
.ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
[Nota: ssh-copy-id agrega la llave al .ssh/authorized_key del host remoto]

#3:Nos logueamos sin poner la contraseña:

3caram@local-host$ ssh usuario_host_remoto@ip_host_remoto
Last login: Sun Nov 16 17:22:33 2008 from x.x.x.x
[Nota: SSH no pidió contraseña]
usuario_host_remoto@ip_host_remoto$ [Note: estas ahora en el host remoto]

No comments: