Copy and Run a Java/Spring Boot Jar File on a Remote Server via Terminal

Follow the steps below to copy a Java/Spring Boot jar file from your local machine to a remote EC2 Linux/Ubuntu server and run the jar file via terminal:

To Copy a Local File To Remote Server

Open terminal on your local machine and run the following scp (secure copy) command to copy a file from your localhost to a remote ec2 server:

sudo scp -i "your-remote-server.pem" my-file.jar

To Run a Jar File on a Remote Server using ssh

Open terminal and ssh to your remote server:

sudo ssh -i "your-remote-server.pem"

Run the copied jar file in dev environment using the following command:

java -jar my-file.jar