¿Cómo permitir el acceso SSH sin solicitar password?

0
613

Esto es útil para generar scripts que utilizen el protocolo SSH en modo autoático, es decir, que sean no interactivo.

Los pasos son los siguientes:

user_A@maq_remota $ ssh-keygen -t dsa
# (sin passphrase)

user_B@maq_local $ ssh maq_remota -l user_A “cat .ssh/id_dsa.pub” >> ~/.ssh/authorized_keys2

Ahora se puede conectar desde:
user_A@maq_remota a user_B@maq_local
sin usar password utilizando el protocolo SSH 2.

Existe tambien otro escenario real

[dvarela@localhost]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/dvarela/.ssh/id_rsa):
Created directory ‘/home/dvarela/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/dvarela/.ssh/id_rsa.
Your public key has been saved in /home/dvarela/.ssh/id_rsa.pub.
The key fingerprint is:
2a:b6:84:6b:b8:80:ef:e9:6a:d0:13:7d:7b:97:b7:3d dvarela@localhost.localdomain
[dvarela@localhost]$ cd .ssh/
[dvarela@localhost .ssh]$ ls
id_rsa  id_rsa.pub

[dvarela@localhost .ssh]$
[dvarela@localhost .ssh]$ scp id_rsa.pub dvarela@fenix:/home/dvarela/.ssh
dvarela@fenix’s password:
id_rsa.pub                                                 100%  414     0.4KB/s   00:00

[dvarela@localhost .ssh]$ ssh fenix
dvarela@fenix’s password:
Last login: Tue Apr 29 10:01:44 2008 from localhost.localdomain
[dvarela@fenix .ssh]$
[dvarela@fenix ~]$ cd .ssh/
[dvarela@fenix .ssh]$ ls id_rsa.pub  known_hosts
[dvarela@fenix .ssh]$

[dvarela@fenix .ssh]$ mv id_rsa.pub authorized_keys2
[dvarela@fenix .ssh]$ chmod 0600 authorized_keys2
[dvarela@fenix .ssh]$ ls -la
total 20
drwx—— 2 dvarela dvarela 4096 Apr 29 10:26 .
drwx—— 7 dvarela dvarela 4096 Apr 28 23:41 ..
-rw——- 1 dvarela dvarela  414 Apr 29 10:25 authorized_keys2
-rw-r–r– 1 dvarela dvarela  643 Apr 25 20:27 known_hosts
[dvarela@fenix .ssh]$ logout
Connection to listas closed.

[dvarela@localhost ~]$
[dvarela@localhost ~]$
[dvarela@localhost ~]$
[dvarela@localhost ~]$ ssh fenix
Last login: Tue Apr 29 10:27:28 2008 from localhost.localdomain
[dvarela@fenix ~]$
[dvarela@fenix ~]$
pwd
/home/dvarela
[dvarela@fenix ~]$



 

LEAVE A REPLY

Please enter your comment!
Please enter your name here