Here I have a script that answers a question posted on the opensuse.org.suse-linux.support forums.
1. The script first removes the ~ backup files from the source directories.
2. It then copies the files to the web server using scp.
3. Using the ssh command it then changes the permissions on the the directories.
Note the -depth option is important. It means the directories at the bottom of the structure are changed before directories further up. This avoids an issue where permissions might be changed that stop you from changing into a lower directory.
4. The ssh command is used again to change the permissions of the files.
#!/bin/bash
# (c) Jim Pye 20060206
#Remove backup ~ files
find /local/develop/dir/www-site/ -depth -type f -name '*~' -exec /bin/rm {} \;
echo "Copying the files to site"
scp -C -r /local/develop/dir/www-site/* user@webserver:/srv/www/htdocs/
echo "Changing Directory permissions"
ssh -C user@webserver "/usr/bin/find /srv/www/htdocs/ -depth -type d -name '*' -exec /bin/chmod -c 0705 {} \;"
echo "Changing File Permissions"
ssh -C user@webserver "/usr/bin/find /srv/www/htdocs/ -depth -type f -name '*' -exec /bin/chmod -c 0604 {} \;"