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
What’s the deal with encryption strength —is 128 bit encryption enough or do you need more?
4 Ways to Earn Money With Brave Browser - Browser To Use
Star Wars Mongol Heleer
Atvs For Sale By Owner Craigslist
³µ¿Â«»ÍÀÇ Ã¢½ÃÀÚ À̸¸±¸ ¸íÀÎ, ¹Ì±¹ Ķ¸®Æ÷´Ï¾Æ ÁøÃâ - ¿ù°£ÆÄ¿öÄÚ¸®¾Æ
Martha's Vineyard Ferry Schedules 2024
Georgia Vehicle Registration Fees Calculator
Gabrielle Abbate Obituary
Encore Atlanta Cheer Competition
Emmalangevin Fanhouse Leak
Atrium Shift Select
Bme Flowchart Psu
Santa Clara Valley Medical Center Medical Records
House Of Budz Michigan
Hilo Hi Craigslist
DoorDash, Inc. (DASH) Stock Price, Quote & News - Stock Analysis
Enterprise Car Sales Jacksonville Used Cars
Cashtapp Atm Near Me
Alexander Funeral Home Gallatin Obituaries
Harem In Another World F95
Charter Spectrum Store
CDL Rostermania 2023-2024 | News, Rumors & Every Confirmed Roster
Certain Red Dye Nyt Crossword
Craigslist Roseburg Oregon Free Stuff
Geico Car Insurance Review 2024
Craftybase Coupon
130Nm In Ft Lbs
Osrs Important Letter
Lehpiht Shop
Http://N14.Ultipro.com
Goodwill Thrift Store & Donation Center Marietta Photos
Polk County Released Inmates
School Tool / School Tool Parent Portal
Myanswers Com Abc Resources
Cal Poly 2027 College Confidential
Wal-Mart 140 Supercenter Products
Gopher Hockey Forum
Chase Bank Zip Code
How to Install JDownloader 2 on Your Synology NAS
Funkin' on the Heights
Rise Meadville Reviews
Anonib New
Christie Ileto Wedding
Mlb Hitting Streak Record Holder Crossword Clue
San Diego Padres Box Scores
Erica Mena Net Worth Forbes
Razor Edge Gotti Pitbull Price
Tommy Gold Lpsg
Bumgarner Funeral Home Troy Nc Obituaries
Vt Craiglist
Ranking 134 college football teams after Week 1, from Georgia to Temple
Supervisor-Managing Your Teams Risk – 3455 questions with correct answers
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.