Permission denied (publickey). while using SCP command

Solution 1:

Based on your answers in the comments, your servers are Amazon EC2 instances, which confirms that this very much is an authentication issue. You will need to use scp with the -i option and include the .pem that you use while SSHing into the machine:

scp -i ~/.ssh/amazon.pem ubuntu@xxxxxxx:/opt/apache-tomcat-9.0.48/conf/server.xml .

Be sure to replace ~/.ssh/amazon.pem with the actual name and location of your private key.