🖥️scp

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the scp command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ███████╗ ██████╗██████╗ 
#                ██╔════╝██╔════╝██╔══██╗
#                ███████╗██║     ██████╔╝
#                ╚════██║██║     ██╔═══╝ 
#                ███████║╚██████╗██║     
#                ╚══════╝ ╚═════╝╚═╝     
                

# To copy a file from your local machine to a remote server:
scp foo.txt [email protected]:remote/dir

# To copy a file from a remote server to your local machine:
scp [email protected]:remote/dir/foo.txt local/dir

#==============================#
# CMD SCP
#==============================##==============================#
scp -vvv
# Remember, if something isn not working, there is a reason and you can often find that reason using more -v options (or strace)

scp(){ [[ "$@" =~ : ]] && /usr/bin/scp "$@" || echo 'You forgot the colon!'; }
# Wrapper function to catch a common scp mistake.

scp(){ [[ "$@" =~ : ]] && /usr/bin/scp "$@" || echo 'You forgot the colon!'; }
# Wrapper function to catch a common scp mistake.

scp -vvv
# Remember, if something isn not working, there is a reason and you can often find that reason using more -v options (or strace)

scp ./file:with:colons.txt user@otherhost: 
# Filename with colons giving you problems with scp or rsync? Use the ./ path prefix B4 filename.

scp source_file_name username@destination_host:destination_folder
#    The “-p” parameter will help you on this. An estimated time and the connection speed will appear on the screen.
#    You can use “-v” parameter to print debug information into the screen. 
#         It can help you debugging connection, authentication and configuration problems.
#    The “-C” parameter will compress your files on the go

scp -r documents [email protected]:.
# Sometimes we need to copy directory and all files / directories inside it. It will be better if we can do it in 1 command. SCP support that scenario using “-r” parameter. When the copy process is done, at the destination server you will found a directory named “documents” with all it’s files. The folder “documents” is automatically created.

# Examples for scp
######################## 
# scp is based on ssh & is used to transfer file from local host to remote host securely.  
# Syntax for using scp is
scp source_file_name username@destination_host:destination_folder

scp –rpv /datafile [email protected]:/home/susan
# here, option r is used when we are copying a directory with all the files inside it,
# secondly option p will provide an estimate time & connection speed,
# and option v will provide debugging information which can help in diagnosing a problem related to                              connection, authentication etc.

scp –C /datafile [email protected]:/home/susan
# option C here will compress the file on the go & will reproduce the same file when it arrives at the destination. Thus saving time consumed for copying the file.

scp –P 300 /datafile [email protected]:/home/susan
# here option –P is used to define a custom port incase we are not using default ssh port (22).

 
#==============================##==============================#
# CMD SCP
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░