Remote Copying With the scp Command (2024)

Remote Copying With the scp Command

The scp command copies files or directories between a local and a remote systemor between two remote systems. You can use this command from a remotesystem (after logging in with the ssh command) or from the local system.The scp command uses ssh for data transfer. Thus, the scp command uses thesame authentication and provides the same security as the ssh command.

With scp, you can perform the following remote copy operations:

  • Copy a file or directory from your local system to a remote system

  • Copy a file or directory from a remote system to your local system

  • Copy a file or directory between remote systems from your local system

Security Considerations for Copy Operations

To copy files or directories between systems, you must have permission to login and copy files.

The scp command, as a component of the ssh command, requires that youhave either a user account or host key access to the target system.Consult Chapter 15, Using Secure Shell, in Oracle Solaris 11.1 Administration: Security Services for further information.

Remote Copying With the scp Command (1)

Caution - Both the cp and scp commands can overwrite files without warning. Ensure thatfile names are correct before executing the command.

Specifying the Source and Target for Copy Operations

With the scp command, you can specify the source (the file or directoryto be copied) and the target (the location in which to copy the file ordirectory). You can shorten the path strings by using the tilde character (~)and the shell wildcard characters (*, ?, and so forth).

The tilde character (~) is expanded by all shell programs to be thecurrent user's home directory. The current user is the user under which theshell is executing. If the home directory for the user jack is /export/home/jack, thenfor the user jack, ~/myfile.txt expands to /export/home/jack/myfile.txt.

This expansion also works for remote paths. If the user jack wantsto copy a file from his home directory, then these three path descriptionsare equivalent:

  • mars:/export/home/jack/myfile.txt

  • mars:~/myfile.txt

  • mars:myfile.txt

This expansion is also useful when referring to another user's remote home directory.In this case, you would include the user's name after the tilde character.For the user jack, mars:~jill/myfile.txt is equivalent to mars:/export/home/jill/myfile.txt, but it isshorter to type.

How to Copy a File Between Two Systems (scp)

  1. Ensure that you have permission to copy files on the target system.

    The scp command requires authentication. Depending upon the method of authentication used, youmust have either an account on the target system, or an authorizedpublic key on the target system. You should at least have read permission onthe source system and write permission on the target system.

    Remote Copying With the scp Command (2)

    Caution - If you do not have an account on the target system, or ifthe target system is not configured to allow public keys, you will receive anauthentication error. For example:

    $ scp mars:/var/tmp/testdir/letter.txt .Permission denied (gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive)

    Ensure that you have either a user account or public key access configuredon the target system for authentication. See Secure Shell Authentication in Oracle Solaris 11.1 Administration: Security Services.

  2. Determine the location of the source and target.

    If you don't know the path of the source or target, you canfirst log in to the remote system with the ssh command, as described inLogging In to a Remote System (ssh). Then, navigate through the remote system until you find the location. Youcan then perform the next step without logging out of the remote system.

  3. Copy the file or directory.
    $ scp [-r] [[user1@]hostname1:]file1 ... [[user2@]hostname2:]file2
    -r

    Use to recursively copy entire directories.

    user1, user2

    Login account to use on the remote host.

    hostname1, hostname2

    The names of the remote host from or to which the file is to be copied.

    file1

    The file name or directory name to be copied. Several source file names may be included on one command line.

    file2

    The destination file name or directory name.

Example3-5 Using the scp Command to Copy a Remote File to a Local System

In this example, scp is used to copy the file letter.doc from the/home/jones directory of the remote system pluto to the working directory on thelocal system.

$ scp pluto:/home/jones/letter.doc .The authenticity of host 'pluto (192.168.56.102)' can't be established.RSA key fingerprint is b4:88:7b:cf:f5:23:d3:ad:0b:14:22:31:74:7b:6c:74.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.56.102' (RSA) to the list of known hosts.Password:letter.txt 100% |*****************************| 23 00:00 $ 

In this example, this is the first time the system pluto isaccessed, hence, the RSA key fingerprint message.

Here, the “.” symbol at the end of the command line refers to thecurrent working directory on the local system.

Example3-6 Using the scp Command to Copy a Local File to a Remote System

In this example, scp is used to copy the file notice.doc from thehome directory (/home/smith) of the local system earth to the /home/jones directoryof the remote system, pluto.

$ scp notice.doc pluto:/home/jonesPassword:notice.doc 100% |*****************************| 0 00:00 

Because no remote file name is provided, the file notice.doc is copiedinto the /home/jones directory with the same name.

In the following example, the scp operation from the previous example is repeated,but scp is executed from a different working directory on the local system(/tmp). Note the use of the “~” symbol to refer to the current user'shome directory:

$ scp ~/notice.doc pluto:/home/jonesPassword:notice.doc 100% |*****************************| 0 00:00

Copyright © 2002, 2012, Oracle and/or its affiliates. All rights reserved. Legal Notices

Remote Copying With the scp Command (2024)
Top Articles
Teacher Tech Tools 💻 - Power Wash
What bank does turbo tax use to do direct deposits
Umbc Baseball Camp
Dannys U Pull - Self-Service Automotive Recycling
Asist Liberty
Repentance (2 Corinthians 7:10) – West Palm Beach church of Christ
Samsung 9C8
Yi Asian Chinese Union
Tanger Outlets Sevierville Directory Map
Optum Medicare Support
Citi Card Thomas Rhett Presale
Savage X Fenty Wiki
Dallas’ 10 Best Dressed Women Turn Out for Crystal Charity Ball Event at Neiman Marcus
finaint.com
Stihl Km 131 R Parts Diagram
Wizard Build Season 28
Transfer and Pay with Wells Fargo Online®
Faurot Field Virtual Seating Chart
The Blind Showtimes Near Amc Merchants Crossing 16
Craigslist Personals Jonesboro
About My Father Showtimes Near Copper Creek 9
Bòlèt Florida Midi 30
Paris Immobilier - craigslist
Skymovieshd.ib
Craigslist Boerne Tx
Amazing Lash Bay Colony
What Is The Lineup For Nascar Race Today
Worlds Hardest Game Tyrone
Craigslist Red Wing Mn
Kvoa Tv Schedule
Cross-Border Share Swaps Made Easier Through Amendments to India’s Foreign Exchange Regulations - Transatlantic Law International
Magicseaweed Capitola
Enjoy4Fun Uno
Delaware judge sets Twitter, Elon Musk trial for October
Hingham Police Scanner Wicked Local
Claim loopt uit op pr-drama voor Hohenzollern
Stanley Steemer Johnson City Tn
Verizon Outage Cuyahoga Falls Ohio
Hireright Applicant Center Login
Devon Lannigan Obituary
Tripadvisor Vancouver Restaurants
Oklahoma City Farm & Garden Craigslist
N33.Ultipro
Backpage New York | massage in New York, New York
Haunted Mansion Showtimes Near Millstone 14
Brutus Bites Back Answer Key
Suzanne Olsen Swift River
Unbiased Thrive Cat Food Review In 2024 - Cats.com
Electronics coupons, offers & promotions | The Los Angeles Times
Heisenberg Breaking Bad Wiki
Latest Posts
Article information

Author: Arielle Torp

Last Updated:

Views: 6205

Rating: 4 / 5 (41 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Arielle Torp

Birthday: 1997-09-20

Address: 87313 Erdman Vista, North Dustinborough, WA 37563

Phone: +97216742823598

Job: Central Technology Officer

Hobby: Taekwondo, Macrame, Foreign language learning, Kite flying, Cooking, Skiing, Computer programming

Introduction: My name is Arielle Torp, I am a comfortable, kind, zealous, lovely, jolly, colorful, adventurous person who loves writing and wants to share my knowledge and understanding with you.