I'm trying to write a bash script which, among several other things, will "log in" as a user (preferably with su if possible) without needing to interact with the password prompt, i.e., will automatically input the password. I only need it to perform one command and then the session can end.
This is for an "automatic checker" for an introductory Linux class I'm teaching. The students have an exercise where they create usernames with specific passwords on their Raspberry Pis (running Raspbian), and I want this script to automatically verify the passwords are correct. The students run the "automatic checker" on their Pis and I verify the output, so they have a chance to fix any errors before turning in. Since this is for a classroom exercise with dummy passwords, the security of these passwords is completely irrelevant.
I know there are already a few questions about automatic logins, but none of them work for me. The closest I've come to a solution is getting the su command to say a terminal is required. Using "expect" will not work because it will require installing packages on the students' Pis.
If there are other ways to verify the passwords are correct then I'm open to those. I don't think I can do a hashed password comparison due to the salt.