Use SCP to securely transfer files between two Unix computers (2023)

  • Go to content
  • Go to search
  • Go to application

andUnix, you can use SCP (scpcommand) to securely copy files and folders between remote computers without bootingFTPsessions or explicitly connect to remote systems. Thatscpuser of the commandSSHto transfer data, so a password or code is requiredApproval. Differentrcpor FTP,scpencrypts both the file and all exchanged passwords so that no one snooping on the network can see them.

Note:

Using two-factor authenticationTwo-step connection (Duo)required to access connection nodes in the IUsupercomputer researchand for SCP and SFTP file transfers on these systems. SSH public key authentication remains an option for submitting researchers"SSH Public Key Authentication on HPS Systems" after that.(Application indHPCeverywhere, everywhereusing your ownIU username and password), where you agree to provide the password for your private key when you generate your key pair. If you have questions about how two-factor authentication can affect your workflows,kontakt UITS Research Applications and Deep Learning-teamet. For help, seeGet started with two-step login (Duo) on IUiHelp for two-step login (Duo).

Pension

Pension forscpthe command is:

scp [επιλογές] username1@sourcehost:folder1/filename1 username2@destinationhost:folder2/filename2

The source file location is specifiedusername1@sourcehost:folder1/filename1, Which contains:

  • host account name (username 1)
  • The name of the host computer where the source file is located (original_host)
  • The name of the folder containing the source file (card 1)
  • Source file name (file name 1)

The location to which the source file is copied is specifiedusername2@destinationhost:folder2/filename2, Which contains:

  • Account name on the target computer (username 2)
  • The name of the computer to which the source file will be copied (destination_host)
  • The name of the folder where the source file will be copied (card 2)
  • Copy file name (file name 2)

Note:

Be sure to include a space between the source and destination paths. Also, be careful when copying files with the same name to both hosts. you may accidentally overwrite data you intended to keep.

For more aboutscp, consult himmanual side. At the Unix prompt, type:

scp mand

At Indiana University, for personal or departmental support for Linux or Unix systems, seeGet help for Linux or Unix on IU.

Examples

For the following examples, let's assume that your username isdvader, and you are logged in to your computer accountcarstvo.gov:

  • To copy the file namedrebels.txtfrom your home foldercarstvo.govin the so-called foldervengeanceto your computer accountdeathstar.com, Nurse:
    scp ~/rebels.txt dvader@deathstar.com:~/osveta

    You will be prompted for a password on the target system (deathstar.com). The command will not work if you do not enter the correct password.

  • To copy a folder (and all the files it contains), usescps-rChoice. That's what it saysscpto retroactively copy the original library and its contents.

    Da sve kopiramvengeancefolder from yourdeathstar.comYour user accountcarstvo.govaccount, enter:

    scp -r dvader@deathstar.com:~/osveta ~/osveta

    You will be prompted for the password on the source system (deathstar.com). The command will not work if you do not enter the correct password.

  • To copy multiple files to a folder, you can use wildcards (eg*the?). However, to use wildcards to copy multiple source files from a remote system, enclose them in quotation marks ("") around the path to the source files. This is necessary because Unixmora, yesscpcommand, expands unquoted wildcards.

    Therefore, copy everything.textfiles fromvengeancefolder in yourdeathstar.comYour user accountvengeancemap enabledcarstvo.gov, Nurse:

    scp dvader@deathstar.com:"osveta/*.txt" ~/osveta/

    You will be prompted for the password on the source system (deathstar.com). The command will not work if you do not enter the correct password.

For the following example, assume that (dvader) connected to another computer (that is, to another computer that is notcarstvo.govthedeathstar.com). Copyluke.txtfrom your home foldercarstvo.govyoursvengeancemap enableddeathstar.com, Nurse:

scp dvader@empire.gov:~/luke.txt dvader@deathstar.com:~/revenge

You will be asked to enter two passwords: one for the source system (carstvo.gov) and one to the target system (deathstar.com). The command will not work if you do not enter both passwords correctly.

This is a document Received in the knowledge base.
Last changed 21-08-2023 11:18:44.

References

Top Articles
Latest Posts
Article information

Author: Eusebia Nader

Last Updated: 09/30/2023

Views: 6154

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.