I have a script running as a root. It ssh to remote host and run a script as user gol. I have added ssh keys for the user(gol) to remote host. But since the script is run as a root it still prompts for a password. The script content is below
ssh gol@remotehost '/home/scripts/script1.sh'
so i changed the command to switch to local user before running the ssh command (because gol user has ssh keys added) but it fails.
su - gol -c ssh gol@remotehost '/home/scripts/script1.sh'
I need to run this as root as there are other scripts along with this script.