I have checked many postings regarding 'Permission denied' error in using
scp, but couldn't find the answer for my problem.
There are two ubuntu servers (let's say server 'A' and 'B') on the same network in AWS, and when I tried to copy one file to another server, A to B is not working, but from B to A works. (Please see below)
On Server 'A',
ubuntu@server-a ~ $ ls -alt server* -rwxr-xr-x 1 ubuntu ubuntu 8152 Aug 9 14:26 server.xml.bak ubuntu@server-a ~ $ scp -P 443 server.xml.bak email@example.com:/home/ubuntu/ Permission denied (publickey). lost connection ubuntu@server-a ~ $ scp -P 443 /home/ubuntu/server.xml.bak firstname.lastname@example.org:/home/ubuntu/ Permission denied (publickey). lost connection
Also I tried to copy the remote file to here, and it failed as well.
ubuntu@server-a ~ $ scp -P 443 email@example.com:/home/ubuntu/sakila.sql . Permission denied (publickey).
But from Server 'B', all worked.
ubuntu@server-b ~ $ scp -P 443 firstname.lastname@example.org:/home/ubuntu/server.xml.bak . server.xml.bak 100% 8152 8.0KB/s 00:00 ubuntu@server-b ~ $ scp -P 443 sakila.sql email@example.com:/home/ubuntu/ sakila.sql 100% 3153KB 3.1MB/s 00:00
As you see, it is not the permission issue - all operations were done by 'ubuntu' on 'ubuntu' home and files are also owned by 'ubuntu' with 755 mode.
So now I'm confused what is wrong.