samedi 17 janvier 2015

.bashrc custom secondary password and SCP is not working, (SSH secondary password)


for "some purpose" i have added a script in the ~/.bashrc to prompt for a secondary password and its serves my purpose. But, there is only one small issue is there.


When I scp to the server, It fails due to my custom script in the ~/bashrc The error I am getting when doing a scp is "stdin: is not a tty"


I invoke "sh second_pass.sh" from the ~/.bashrc


Content of sh second_pass.sh



trapeze () {
printf "Trying to kill me!!" }

trap trapeze SIGINT

while true; do echo "Please enter the password:" read -s password

if [[ -z "$password" ]] ; then
continue ; fi

hash="$(echo -n "$password" | md5sum )" password=`echo "$hash" | awk '{print $1}'`

if [ "$password" == "a359c98e8c0503feaf91bdb8cfc7dd6b" ] then
exit ; else
echo "WRONG!!!" fi done


the result is, when I do scp is



stdin: is not a tty
Please enter the password:


and then scp fails.


I want to use the scp & also keep the password prompting script in my ~/.bashrc Please let me know, How can I achieve it ?



Aucun commentaire:

Enregistrer un commentaire