Trying to script rsync using pam_exec
- by Ricky-Rose
I'm trying to write a bash script that will execute rsync when called by pam_exec. I've tried a couple different ways, and I'm not sure what I'm doing wrong.
When I try to run the script at login by adding
session optional pam_exec.so /usr/bin/local/sync.sh
to my sshd file, it gives me an exit code of 12.
if I log in and then manually run my script, it allows me to connect to the remote server, and it lists my files, but it doesn't actually sync anything.
I have tried the code below using buth $USER and $PAM_USER. $PAM_USER doesn't work at all.
#!/bin/sh
rsync -azv -e ssh $USER@remote_server:/home/html/$USER/ /home/html/$USER