10

I have scripted a process that involves updating symbolic links on files located on 3 different machines. On those machines exists 4 users each, who each need to have these links updated.

Using su, is there a way to pass the password argument to the command on a single line, without invoking sudo as the users will not have admin rights?

My only alternative solution at this point is to ssh around, however I would like to be able to do this without hardcoding in a bunch of hosts/ips.

1 Answers1

7

You can pipe the password to su like this:

echo pa$$w0rd | su -c whoami user_1
gogators
  • 1,323
  • 7
  • 14