Most problems with Cron scripts are caused by the fact that Cron executes the scripts in a reduced shell, not the standard login shell. So something that works from the terminal or when run in a Bash script may not work when run from Cron. To resolve this, you have to give the full path to all binaries (except for the core utilities).
So for example, you would find where the ssh binary is installed:
Code:
tj@T-Bird:~$ which ssh
/usr/bin/ssh
And then modify your script to call it directly:
Code:
#!/bin/sh
# Path to ssh binary
SSHPATH="/usr/bin/ssh"
$SSHPATH -i /home/user/.ssh/sshkey -l username server cat file.txt > /home/user/Desktop/file2.txt
Again, that is the most common problem in situations like these with Cron. There might be some SSH-specific issue that I am not thinking of here that is causing the actual problem. But this is certainly worth a shot before you take the diagnosis any farther.