scp command is used for transferring files between two server over SSH. Most of scp users getting confused scp command is already available on my system but it still showing “bash: scp: command not found”. So remember that scp command must be available on both local and remote systems.
Install Package for SCP command
scp command is comes from package openssh-clients on Red Hat systems and package openssh-client is used for Debian based systems. Use following commands to install package for scp command on Linux operating systems.
On CentOS/RHEL and Fedora
# yum install openssh-clients
On Ubuntu and Debian
$ sudo apt-get install openssh-client
Transfer File Using SCP command
Local to Remote: To transfer file /opt/myfile.txt from local to remote (remote.example.com) system’s /opt/ directory use following command.
# scp /opt/myfile.txt remote.example.com:/opt/
Remote to Local: To transfer file /opt/myfile.txt from remote (remote.example.com) system to local systems /opt directory use following command.
# scp remote.example.com:/opt/myfile.txt /opt/