Facebook Twitter Instagram
    Trending
    • Bash Scripting Introduction
    • How to change your hostname
    • Configuring a static IP on AlmaLinux
    • How to migrate from CentOS 8 to a supported distro
    • Hands on with Rocky Linux 8.3 RC
    • AlmaLinux is Here!
    • AlmaLinux launches in 1 week
    • How to transfer files with SCP command
    Facebook Twitter Instagram
    The Linux Lab
    • Home
    • AlmaLinux

      How to change your hostname

      April 11, 2022

      Configuring a static IP on AlmaLinux

      February 12, 2022

      AlmaLinux is Here!

      March 30, 2021

      AlmaLinux launches in 1 week

      March 24, 2021

      AlmaLinux Beta 1 is here!

      February 2, 2021
    • CentOS
    • Rocky Linux
    • Tutorials
    • About Us
    The Linux Lab
    You are at:Home»Tutorials»How to transfer files with SCP command

    How to transfer files with SCP command

    0
    By Travis on February 9, 2021 Tutorials
    Advertisement

    When you’re working with systems, you’re going to end up needing to transfer files between your system and a remote system or even two remote systems. Unix systems have this really great program installed by default called scp which stands for secure copy. This is a handy program which lets you transfer files or a complete directory:

    • from your local system to a remote system
    • from a remote system to your local system
    • between two remote systems

    For instance, lets say that I have a 250 MB tar archive I want to move between two servers. Instead of downloading that file to my system and then uploading it again to the other server, I can use scpto transfer it between both systems from my remote system.

    Advertisement

    SCP Syntax

    scp is very easy to use and has some very straight forward syntax:

    scp [OPTIONS] [[user@]SRC_HOST:]file1 [[user@]DEST_HOST:]file2

    • OPTIONS – scp options such as cipher, ssh configuration/port, limit, recursive copy, identity file, etc.
    • [[user@]SRC_HOST:]file1 – the file/directory you want to copy
    • [[user@]DEST_HOST:]file2 – the receiving host and the file/directory name

    Before you copy

    scp uses ssh to transfer data across the network. That means in order to copy the data to the other system, you need to have ssh access – either through a username and password or a username and public/private key. It’s also important to know that the colon is how systems are distinguished by scp.

    Copying a file between two systems

    This is primarily how I use scp. I work with a lot of virtual hosts and occasionally an ISO image is available on one host but not the other. To send it to the other host, I use the following:

    scp centos7.iso root@10.19.42.37:/var/lib/vz/template/iso/centos7.iso

    centos7.iso is the file on the current system where I am currently located. This is the file I want to copy to the remote system. I am connecting to the other system as the root user. The other system’s IP address is 10.19.42.37. /var/lib/vz/template/iso is the directory structure where I am placing the file. centos7.iso is the file name on the remote system I am writing to.

    When you run the command, you’ll be prompted for the password.

    facebookShare on Facebook
    TwitterTweet
    FollowFollow us

    Advertisement
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleAlmaLinux Beta 1 is here!
    Next Article AlmaLinux launches in 1 week
    Travis

    I am a Cloud Engineer currently working in the financial and web hosting industry. My passion has been Linux since I first discovered it in 2005. Throughout my career, I have always implemented Linux wherever possible and am an advocate of using open source software over proprietary whenever possible. I strongly believe in the UNIX philosophy of "Do One Thing and Do It Well". I started The Linux Lab as a way for people to discover Linux (and UNIX in general, even macOS users) and to find solutions to problems and learn about Linux.

    Related Posts

    Bash Scripting Introduction

    How to change your hostname

    Leave A Reply Cancel Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Buy Me a Coffee

    Recent Posts
    • Bash Scripting Introduction
    • How to change your hostname
    • Configuring a static IP on AlmaLinux
    • How to migrate from CentOS 8 to a supported distro
    • Hands on with Rocky Linux 8.3 RC
    Recent Comments
    • Travis Newton on Zabbix 4.4 on CentOS 8 Installation
    • Gulman on Zabbix 4.4 on CentOS 8 Installation
    • Sam Andrews on SSH Clients – Which is best?
    • gila on Zabbix 4.4 on CentOS 8 Installation
    • Alex on Zabbix 4.4 on CentOS 8 Installation
    Categories
    • AlmaLinux
    • Bash Scripting
    • CentOS
    • Red Hat
    • Rocky Linux
    • Security
    • Software
    • SSH
    • Tutorials
    • Ubuntu
    • VPN
    • Zabbix
    Copyright © 2022. The Linux Lab.

    Type above and press Enter to search. Press Esc to cancel.

    This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
    Privacy & Cookies Policy

    Privacy Overview

    This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
    Necessary
    Always Enabled
    Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
    Non-necessary
    Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
    SAVE & ACCEPT