Hello, everyone. I have a problem, and I've been searching for an answer all day. Hopefully someone here can help me.
I'm writing a script that will ping every IP address on the subnet, and for each computer that responds, it will ssh in with a username (os) and a password (itnsA0h9), perform some commands, and move on to the next host.
While the username can be specified as part of the ssh command, the password can not, and I can not figure out how to pass the password from my script to the input prompt of the ssh program.
The relevant code:
Code:
echo "Attempting to log in to ${target} (MAC: ${mac})"
ssh os2@${target}
So far I've tried:
Code:
ssh os2@${target} < /home/justus/sshpass.txt #this file contains the password
Code:
echo "itnsA0h9" | ssh os2@${target}
Even:
Code:
ssh os2@${target}
pause 3
echo "itnsAoh9"
I've Googled my problem, and while there are solutions listed, they all suggest adding a authentication key to each machine so that ssh does not ask for a password at all. I do not want to do this, as that would mean adding a key for each machine in my subnet.
I've only my second day scripting with BASH, so I apologize if I'm missing something obvious. Thanks!