It's amazing that 9 years later, this solution still applies.
I was attempting to use scp, under PHP/Apache, to copy a file from a remote file server to the Web server with public key authentication (no passwords were to be used).
Even thought I had configured public key authentication properly (my command worked fine from within PuTTY), my command was failing when executed via the Web server because SSH (via scp's invocation) was looking for a /var/www/.ssh directory; the problem was apparent by examining the verbose output of the scp command. SSH wanted to create the directory, because PHP was spawning the scp process under the "apache" user (whose home directory is /var/www).
Once I had taken the following steps
$ mkdir /var/www/.ssh
$ chown apache:apache /var/www/.ssh
$ chmod 700 /var/www/.ssh
I placed an appropriate "known_hosts" file inside the directory and everything functioned as expected.
Thanks, anonymous user!