Loguearse automáticamente por ssh

sshpass permite realizar conexiones por ssh automáticas, se puede usar para scripts hechos en bash y luego usarlos en cronjobs.

sudo apt-get install sshpass
yum install sshpass 
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
   -f filename   Take password to use from file
   -d number     Use number as file descriptor for getting password
   -p password   Provide password as argument (security unwise)
   -e            Password is passed as env-var "SSHPASS"
   With no parameters - password will be taken from stdin

   -h            Show help (this screen)
   -V            Print version information
At most one of -f, -d, -p or -e should be used

Podemos usa la contraseña en la misma linea de comando:

sshpass -p 'contraseña' ssh usuario@host.com 'df -h'

También se puede almacenar la contraseña en un archivo y luego usarlo.

echo 'contrasena' > archivoConContrasena.txt
chmod 600 archivoConContraseña.txt
sshpass -f /ubicacion/de/archivoConContrasena.txt /usr/bin/ssh  usuario@host
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments