Proyecto

General

Perfil

#!/usr/bin/expect -f
##############################################################################
# Descripcion: Relacion de confianza ssh con todos los servidores de aula
# Fecha: 14-Mar-2012.
# Copyright: 2012 - Manuel Mora Gordillo <manuito @nospam@ gmail.com>
# Instrucciones:
# 1.- Lanzar una unica vez el script "confianza.sh password" para establecer la relacion de confianza ssh
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

if $argc<1 {
send_user "Modo de uso\n"
send_user "$argv0 password \n"
send_user " "
exit
}

set pass [lindex $argv 0]
set servidoresaula [exec ldapsearch -xLLL -h ldap -b cn=ltsp-server-hosts,ou=Netgroup,dc=instituto,dc=extremadura,dc=es "nisNetgroupTriple" | cut -f2 -d "(" | cut -f1 -d "," | grep -v "dn:"]

foreach servidoraula $servidoresaula {

send_user "\n\n########################################################################\n"
send_user "############################# $servidoraula ##################################\n"
send_user "########################################################################\n"

spawn ssh root@$servidoraula
expect {
"Are you sure you want to continue connecting (yes/no)? " {
send "yes\n"
exp_continue
}
"assword: " {
send "$pass\n"
expect {
"# " { }
}

spawn ssh-copy-id root@$servidoraula
expect {
"assword: " {
send "$pass\n"
expect {
"# " { }
}
}
default {
send_user "Login fallido\n"
}
}
}
"# " {
send_user "\nYa tiene confianza ssh\n"
}
default {
send_user "Login fallido\n"
}
}
}

send_user "\nSaliendo...\n"')
(4-4/6)