#!/bin/bash #!/usr/bin/expect IP=192.168.10.100 PASSWORD=root@123 echo -e "\n------------------------------------------------------------------------------------------" echo -e "\t RHEL version" echo "------------------------------------------------------------------------------------------" expect -c "spawn ssh -qo StrictHostKeyChecking=no root@${IP} expect { \"(yes/no)?\" { send \"yes\" expect \"password: \" send \"${PASSWD}\r\" expect \"\\\\#\" send \"uname -r\r\" expect \"\\\\#\" send \"lsb_release -r\r\" expect \"\\\\#\" send \"logout\" } \"password: \" { send \"${PASSWD}\r\" expect \"\\\\#\" send \"uname -r\r\" expect \"lsb_release -r\\\\#\" send \"\r\" expect \"\\\\#\" send \"logout\" } \"# \" { expect \"\\\\#\" send \"uname -r\r\" expect \"\\\\#\" send \"lsb_release -r\r\" expect \"\\\\#\" send \"logout\" } } " echo -e "\n ------------------------------------------------------------------------------------------\n"
Archive for the ‘password pass via expect’ Category
Bash script – How to pass the password using expect in Linux
Posted: March 22, 2018 in password pass via expect, Shell Script0