Suppose you want to copy $local to $remote on $host and add an hourly job that should run 14 times per hour using one SSH session;
ssh "$host" "cat >'$remote' && chmod +x '$remote' && ( crontab -l; echo '14 * * * * $remote' ) | crontab" <"$local"
This can obviously be much more reliable with correct error checking, etc., but hopefully it should at least get started.
Two keys are here: the ssh command accepts an arbitrarily complex shell script as a remote command and receives its standard input from the local host.
(With double quotes around the script, all variables will be interpolated on the local host, so the command executed on the remote host will look like cat >'/path/to/remote' && chmod +x '/path/to/remote' && ... With single quotes, you can have spaces in the file name, but I did not put them in the crontab entry, because it is so strange. If you need single quotes too, I think it should work.)
source share