amazon media file explorer download upload index folder image licenses menu widget Play Pause profile-settings more dots-two-horizontal dots-two-vertical more-vertical pending google-plus hangouts facebook instagram whatsapp spotify telegram twitter vine renren rss youtube twitch vimeo flickr dribble behance deviantart 500px steam github soundcloud skype reddit linkedin lastfm delicious stackoverflow pinterest xing flattr foursquare yelp World

Transferring files with scp In [Ubuntu]

I recently wrote a basic guide on transferring files with rsync, and I outlined some examples, while rsync is really powerful, the major problem I have with it is that it doesn't support the transfer of files from one remote host to another, it works with local to remote, and vice verse.

This is where scp overshines, secure copy (scp) relies on SSH to transfer files between hosts one a network, the good thing is it uses the same authentication and provides the same security as ssh. scp will ask for passwords or passphrases if they are needed for authentication.

Note: I would be using the simplifying my SSH connections, this way, I won't need to manually type the server I am connection to by hand, Learn how to do so in the guide below:

SCP is similar to rsync, the same rules apply; it requires a source (where you are copying from), and a target (where you are copying to).

Transferring a File Locally To a Remote Host

scp /home/user/testfile.txt ServerA:/backup

The above command is copying file testfile.txt from the user directory to a backup directory in ServerA.

If you do not specify a directory in the target server, it would copy to the home directory of the target server as specified in your SSH config file.

Transferring a File From Remote Host To a Local Server

This is the reverse of the above command:

scp ServerA:/backup/testfile.txt /home/user

This would copy testfile.txt from the ServerA backup directory into the user local directory.

Downloading an Entire Directory, and Its Contents

To download, and copy an entire directory with its content, you add and -r option, which does a recursive copy of the entire directory, for example:

scp -r /home/user/bookd ServerA:downloads

Since you added the -r option, it will transfer the book folder and
all of its contents into the serverA download folder, so, say the user of the ServerA is James, it would transfer the file under /home/james/downloads.

If you want the command to show you the details of what is going on, you can ass the -v option, this would show you how the command progresses as it copies multiple file, e.g:

scp -rv /home/user/bookd ServerA:downloads

For those not using SSH config, scp assumes that SSH is listening on port 22 on the remote machine, so, if your SSH port has been changed, you can add designate a different port with the -p option:

scp -P 2222 -r /home/user/books faruq@

Note: The above command only applies for does not using SSH config.

Related Post(s)

  • How To Access Windows 10 Drive/Folder in VirtualBox

    To access Windows drive or folder in your Guest OS, you first of all, install VirtualBox guest utilities: sudo apt-get install virtualbox-guest-utils You then Add a shared folder by going into: Setti

  • Send Mail with Attachment Using Mutt in GNU/Linux

    Mutt is a powerful text-based mail client for Unix/Linux operating systems. It features color support, message threading, MIME support...

  • Using Pageant To Automatically Authenticate SSH key in Putty

    I can't count how many times I have typed my ssh key passphrase whenever my ssh connection times out, it is so annoying and repetitive. Well, thanks to the putty pageant, you can do that seamlessly.

  • Installing WP-CLI In a GNU/Linux Server

    WP-CLI is a command-line interface for WordPress. It can also be used with ClassicPress, as they are no differences in their usage, maybe just minimal if you are updating or downloading new ClassicPr

  • How To Send Mail To Multiple Addresses Using (mailx)

    In this guide, you'll learn a couple of ways you can send mail to multiple addresses using mailx. mailx is a utility program for sending and receiving mail. I assume you already have mailx command, i

  • Mounting and Unmounting Cloud Storage With (Rclone) in GNU/Linux

    Ever wondered if you could mount your preferred cloud storage as a virtual drive on your system? Thanks to Rclone, you can mount and access different kinds of cloud storage from a file manager, I'll