Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
scp -i ~/.ssh/id_rsa.pub events*$date*_QA.log $remote_user@$remote_server:$remote_location

Is the aforementioned script incorrect? Am I not doing it correctly?

I went to .ssh directory and see that the remote server is in the known_hosts file.

But, when I do ordinary scp without any file as parameter, it is still asking for password

scp events*$date*_QA.log $remote_user@$remote_server:$remote_location

How can I include the key file in my command?

sh-3.2$ grep server ~/.ssh/*
/home/user/.ssh/known_hosts:server....com,ip_addr ssh-rsa Asine=jhjsdhfjsadhfjkashdfjhasdjfhksadjfhasjdfhj
share|improve this question

1 Answer 1

 -i identity_file
         Selects the file from which the identity (private key) for public
         key authentication is read.  This option is directly passed to

Use ~/.ssh/id_rsa.

share|improve this answer
still asking for password sh-3.2$ scp -i ~/.ssh/id_rsa test_QA.log user@server:location user@server's password: –  user122530 Mar 12 '12 at 21:23
@tech_learner strange, as that works for me –  whitequark Mar 12 '12 at 22:04
You may have to use an actual path, as in /home/user/ instead of ~. That seemed to have made it work for me. –  Evan Darwin Feb 17 '13 at 21:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.