Copy and Run a Java or a Spring Boot Jar File on a Remote AWS Server via Terminal
Follow the steps below to copy a Java or a Spring Boot jar file from your local machine to a remote EC2 Linux/Ubuntu server and run the jar file via terminal:
- Copy a File from Local To Remote Server:
- Run a Jar File on a Remote Server using ssh:
- Open terminal and ssh to your remote server:
- Here's a commnd to run the copied jar file in dev environment using the following command:
Open a terminal on your local machine and execute the following scp (secure copy) command to copy a file from your local host to a remote EC2 server:
sudo scp -i "your-remote-server.pem" my-file.jar user@remotehost.com:/home/destination
sudo ssh -i "your-remote-server.pem" user@ec2-4-3-2-1.us-east-1.compute.amazonaws.com
java -Dspring.profiles.active=dev -jar my-file.jar
You can replace 'dev' and execute the application within an alternate environment as per your specific needs.