From 0b57e3be28f1b42d7cea436feb04fbcdf83e8484 Mon Sep 17 00:00:00 2001 From: Yao Lu Date: Tue, 29 Nov 2016 22:39:37 +0800 Subject: implement deploy on virthal pod Change-Id: I600e21f0d36f37c75cac4ace5f7225e32ab93d56 Signed-off-by: Yao Lu --- deploy/trustme.sh | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 deploy/trustme.sh (limited to 'deploy/trustme.sh') diff --git a/deploy/trustme.sh b/deploy/trustme.sh new file mode 100755 index 00000000..eedda5ce --- /dev/null +++ b/deploy/trustme.sh @@ -0,0 +1,88 @@ +#!/bin/sh +#to be trusted by other host£¬and no password needed when use ssh command + +#check parameters legality +logfile=/var/log/trustme.log +function print_log +{ + local promt="$1" + echo -e "$promt" + echo -e "`date -d today +"%Y-%m-%d %H:%M:%S"` $promt" >> $logfile +} +ip=$1 +passwd=$2 +if [ -z $passwd ]; then + print_log "Usage: `basename $0` ipaddr passwd" + exit 1 +fi + +rpm -qi sshpass >/dev/null +if [ $? != 0 ]; then + print_log "Please install sshpass first" + exit 1 +fi + +#ping other host +unreachable=`ping $ip -c 1 -W 3 | grep -c "100% packet loss"` +if [ $unreachable -eq 1 ]; then + print_log "host $ip is unreachable" + exit 1 +fi + +#generate ssh pubkey +if [ ! -e ~/.ssh/id_dsa.pub ]; then + print_log "generating ssh public key ..." + ssh-keygen -t dsa -f /root/.ssh/id_dsa -N "" <> ~/.ssh/authorized_keys" +if [ $? != 0 ]; then + print_log "ssh $ip to add public key for authorized_keys failed" + exit 1 +fi +print_log "rm tmp file $ip:$tmpfile" +sshpass -p $passwd ssh -o StrictHostKeyChecking=no $ip "rm $tmpfile" +if [ $? != 0 ]; then + print_log "ssh $ip to delete tmp file failed" + exit 1 +fi +print_log "trustme ok!" + -- cgit 1.2.3-korg