copy local file to server ssh code example

Example 1: scp send file

scp ./file.txt remote_username@remote_ip:/remote/directory

Example 2: centos copy files ssh

scp <source> <destination>

#To copy a file from B to A while logged into B:
scp /path/to/file username@a:/path/to/destination

#To copy a file from B to A while logged into A:
scp username@b:/path/to/file /path/to/destination

Example 3: scp server to local

scp [email protected]:/remote/file.txt /local/directory

Example 4: copy file from ssh server to local

scp host_name:file_server path_local

Example 5: copy from remote server

scp -i <KEY CERTIFICATE | .ppk or .pem file> <source URL of local server or remote server> <destination URL of local server or remote server>

Example 6: copy files from local to host ssh

$ scp * remoteuser@remoteserver:/remote/folder/