How to copy file one server from another server in Linux

How to copy file one server from another server in Linux

Simple scp command you can user to copy files one server from another server

1St go to directory which you need to copy ex: you need to copy /etc/copyfoldername

cd /etc/copyfoldername

than run bellow command

After command run it will ask root user password enter root user password than hit Enter

Ex: scp -r * root@Ip_Address:/var/foldername

Ex: scp -r * root@192.168.1.1:/var/foldername

After that it will ask you to enter root password for 192.168.1.1

  • Root –> User name
  • :/Folder path where to past

if SSH port is different run the command with -P port

Ex: scp -P port * root@192.168.1.1:/foldername

  • * –> copy all files under folder if you want to copy single file use bellow command

Ex: scp -P port copyfilename.txt root@192.168.1.1:/foldername

  • -P – Specifies the remote host ssh port.
  • -q – Use this option if you want to suppress the progress meter and non-error messages.
  • -C – This option forces scp to compresses the data as it is sent to the destination machine.
  • -r – This option tells scp to copy directories recursively

If your using different port for ssh and using key-file
run the bellow command on Source Server

scp -r -i /home/admin/filename.pem -P 22222 /folder or file path fromsource/* root@destination server Ip://folder or file path from destination server

-i –> destination server key .pem/.ppk file path
-p –> destination server ssh port

Related posts

Creating a Bootable Installation Media for Ubuntu OS

Secure Your Website with Let’s Encrypt and Nginx: A Step-by-Step Guide

Monitoring Calls with FreeSWITCH CLI: A Comprehensive Guide