54
10
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 the .ssh
directory and saw 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
1You want the local user's ~/.ssh/id_rsa.pub content placed in the remote server's authorized_keys file. It's usually in ~/.ssh/authorized_keys. You also need to be very particular about the file permissions on files in ~/.ssh, making them minimally accessible. sshd is very particular about the file permissions. – JR Lawhorne – 2016-04-07T17:55:26.153
On Mac OS X it only worked if
-i ~/.ssh/id_rsa
was the first option. So this worked:scp -i ~/.ssh/mykey.pem -r dir user@remote_server:~/
. This didn't work:scp -r -i ~/.ssh/mykey.pem dir user@remote_server:~/
– asmaier – 2018-07-12T11:13:45.133still asking for password
sh-3.2$ scp -i ~/.ssh/id_rsa test_QA.log user@server:location user@server's password:
– None – 2012-03-12T21:23:57.663@tech_learner strange, as that works for me – whitequark – 2012-03-12T22:04:05.933
2You may have to use an actual path, as in /home/user/ instead of ~. That seemed to have made it work for me. – Evan Darwin – 2013-02-17T21:15:02.170