Terminal command to download log files through ubuntu from remote end not working

i am not able to download the log files from remote end to local.

first approach:
i tried to use the reversed syntax order of uploading a file onto remote end with my private key got from amazon EC2.
the uploading terminal command i used at local is as below and it worked:
scp -i ~/Downloads/mykey2.pem ~/Desktop/Test.war ubuntu@MY_INSTANCE_IP:~/
so the downloading terminal command i used at local is as below and it did not work:
sudo scp -i ~/Downloads/mykey2.pem ubuntu@MY_INSTANCE_IP:/opt/tomcat/logs/localhost_access_log.2017-09-24.txt ~/Downloads
the terminal popped up with a Password request, so I typed in my login password for my laptop and got denied.
I tried to type the same command again and the terminal denied me again with message below:
scp: /opt/tomcat/logs/localhost_access_log.2017-09-24.txt: Permission denied

second approach:
i copied the txt log file towards under ubuntu path, then use chown command to change the owner to ubuntu, then try downloading with the scp command i used in my first approach. i got message below: ssh: connect to host MY_INSTANCE_IP port 22: Operation timed out

i searched online and saw some reference about how to download logstash log files from remote to local without public or private key. in my situation (i guess many others use key as well to upload earlier) if i have used private key to upload my material-for-deployment. now how to get those log files to local with the same key?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.