Jump to content
  • scp

    Cowboy Denny

    SCP Linux Command – How to SSH File Transfer from Remote to Local

    SCP Syntax

    scp [OPTIONS] [[user@]src_host:]file1 [[user@]dest_host:]file2
    • scp - It initializes the command and ensures a secure shell is in place.
    • OPTIONS - They grant different permissions depending on how they have been used. Some of the most common options include:
    • P(Caps) - specifies the port to establish connection with the remote host.
    • p(lowercase) - preserves the times-tamp for ease of modification and access.
    • r - copies the entire directory recursively
    • q - copies files quietly, doesn't display the progress messages. Also known as quiet mode.
    • C - for compression of data during transmission.
    • To understand more about OPTIONS read scp options
    • src_host - where the file is hosted. The source can either be a client or server depending on the origin of the file.
    • dest_host - where the file will be copied to.


    Copy File from Local Host to Remote Host

    scp test.txt user@destination:/location

    Copy all files ending in php to Remote Host

    scp *.php user@destination:/~/
    • *.php - copies all the files with the .php extension in the currently specified folder.
    • /~/ - means copy them to the home directory.

    Copy a file with one name but save it on remote host with a different filename

    scp -P 8080 test.txt user@destination:/user/home/test2.txt


    Copy Files from Remote Host to Local Host

    scp <remote_username>@<IPorHost>:<PathToFile> <LocalFileLocation>

    Copy File test2.txt from Remote Host to Local Host

    scp user@remotehost:test2.txt .

    Copy Files from Remote Host to another Remote Host

    scp user1@host1.com:/files/test.txt user2@host2.com:/files

    Copy Multiple Files

    scp file1 file2 ... user@<ip_address_of_user>: Destination

    So SCP is a very powerful tool when needing to move files around between systems over the network

    User Feedback

    Recommended Comments

    There are no comments to display.

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Add a comment...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...