Debug School

rakesh kumar
rakesh kumar

Posted on

Secure File Transfer & Deployment Using SCP

When working with servers, secure file transfer is a routine but critical task. This guide explains how to transfer Traccar files, configuration files, and SSL certificates between servers using scp, and how to place them in the correct directories.

Note :Always try to tranfer singlefile or zip file not directory or folder because it would crash
how to go tmp file

 cd /tmp
Enter fullscreen mode Exit fullscreen mode

Understanding SCP Syntax (Most Important)
scp [options] SOURCE DESTINATION

Rules:

SOURCE → Where the file currently exists

DESTINATION → Where the file should be copied to
Enter fullscreen mode Exit fullscreen mode
user@ip:/path means remote server
Enter fullscreen mode Exit fullscreen mode
/path alone means local server
Enter fullscreen mode Exit fullscreen mode
-r is used for directories
Enter fullscreen mode Exit fullscreen mode
  1. Copy Traccar Directory to Remote Server Command
scp -r traccar ubuntu@13.126.68.234:/tmp
Enter fullscreen mode Exit fullscreen mode

Explanation

SOURCE: traccar (local directory)

DESTINATION: /tmp on server 13.126.68.234

Result:


/tmp/traccar
Enter fullscreen mode Exit fullscreen mode

in server first type

cd
cd /tmp
Enter fullscreen mode Exit fullscreen mode

Copy Traccar ZIP Package to Remote Server

scp traccar-linux-64-6.8.1.zip ubuntu@13.126.68.234:/tmp
Enter fullscreen mode Exit fullscreen mode

Explanation

SOURCE:

 traccar-linux-64-6.8.1.zip (local file)
Enter fullscreen mode Exit fullscreen mode

DESTINATION:

 /tmp on remote server
Enter fullscreen mode Exit fullscreen mode
  1. Move Traccar ZIP to /opt Directory (on Remote Server) Command (run on remote server)
sudo mv /tmp/traccar-linux-64-6.8.1.zip /opt/
Enter fullscreen mode Exit fullscreen mode

Explanation

SOURCE: /tmp/traccar-linux-64-6.8.1.zip

DESTINATION: /opt/

Used after SCP to place files in system directories

  1. List Contents of Traccar ZIP (Without Extracting) Correct Command
tar -tf traccar-linux-64-6.8.1.zip

Enter fullscreen mode Exit fullscreen mode

Explanation

Lists files inside the archive

Does not extract anything

  1. Copy Traccar Configuration XML File Command
scp traccarjp.xml ubuntu@13.126.68.234:/tmp
Enter fullscreen mode Exit fullscreen mode

Explanation

SOURCE: traccarjp.xml (local)

DESTINATION: /tmp on remote server

  1. Copy SSL Certificate Files to Remote Server Commands
scp fullchain.cer ubuntu@13.126.68.234:/tmp
scp traccar.motoshare.in.cer ubuntu@13.126.68.234:/tmp
scp traccar.motoshare.in.key ubuntu@13.126.68.234:/tmp
Enter fullscreen mode Exit fullscreen mode

Explanation (same for all)

SOURCE: Certificate file on local machine

DESTINATION: /tmp directory on remote server

  1. Move Traccar Configuration into Correct Directory Command (run on remote server) sudo mv /tmp/traccar.xml.mysqlbac /opt/traccar/conf

Explanation

SOURCE: /tmp/traccar.xml.mysqlbac
Enter fullscreen mode Exit fullscreen mode
DESTINATION: /opt/traccar/conf
Enter fullscreen mode Exit fullscreen mode

Used to activate Traccar configuration

  1. Move SSL Certificates to Apache Certificate Directory Commands (run on remote server)
sudo mv /tmp/fullchain.cer /opt/lampp/etc/certs/traccar.motoshare.in
sudo mv /tmp/traccar.motoshare.in.key /opt/lampp/etc/certs/traccar.motoshare.in
sudo mv /tmp/traccar.motoshare.in.cer /opt/lampp/etc/certs/traccar.motoshare.in
Enter fullscreen mode Exit fullscreen mode

Explanation

SOURCE: /tmp/*.cer or /tmp/*.key
Enter fullscreen mode Exit fullscreen mode
DESTINATION: /opt/lampp/etc/certs/traccar.motoshare.in
Enter fullscreen mode Exit fullscreen mode

This directory is used by Apache for SSL

  1. Quick Reference Table (Source → Destination)

Top comments (0)