Commands:
SCP or secure copy allows secure transferring of files between a local host and a remote host or between two remote hosts. It uses the same authentication and security as the Secure Shell (SSH) protocol from which it is based. SCP is loved for it’s simplicity, security and pre-installed availability.
Copy file from local host to a remote host
$ scp file.txt username@to_host:/remote/directory/
Copy file from a remote host to local host
$ scp username@from_host:file.txt /local/directory/
Copy directory recursively from local host to a remote host
$ scp -r /local/directory/ username@to_host:/remote/directory/
Copy directory recursively from a remote host to local host
$ scp -r username@from_host:/remote/directory/ /local/directory/
📌 TIP: When using scp
with SSH keys setup between the local and remote systems, [TAB]
will auto complete the path on the remote system
The SSH File Transfer Protocol (SFTP), also known as the Secure File Transfer Protocol, enables secure file transfer capabilities between networked hosts. Unlike the Secure Copy Protocol (SCP), SFTP additionally provides remote file system management functionality, allowing applications to resume interrupted file transfers, list the contents of remote directories, and delete remote files.
To enable 'sftp' you might need to edit /etc/ssh/sshd_config
# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server