Using SCP

Command line and GUI clients / 2004-03-14

Not too long ago there was a time when one would update his or her site with their favorite FTP client and manage a server with telnet. Websites were made of static pages, perhaps some fancy SSI, and life was good. Today there is more shunning of clear text transferring, especially with the advent of open networks, wifi, and your local Big Brother. Now you do all you could with telnet and transfer files like FTP, with encrytion, all through one daemon - SSH (secure shell). This document will go over the basics of transferring files with SCP (Secure CoPy). Less widely available is SFTP (over SSH). This document does not cover SFTP, but know that there are pros and cons between SSH and SFTP.

Command line SCP

With ftp (command line), you're used to making the connection, logging in, and then transferring data. With SCP, you'll be doing all of the previous with a single command. As usual you should read the man pages on SCP and check its options. Let's take a look:

you@f00:/home/you$ scp
usage: scp [-pqrvBC46] [-F config] [-S program] [-P port]
[-c cipher] [-i identity] [-o option]
[[user@]host1:]file1 [...] [[user@]host2:]file2

Copy a file to the remote server

Lets say we want to transfer the file /home/f00/myfile.html to a webserver. We want to put it in /var/www/site/ on our server, remote.linux. The format is as follows:

you@f00:/home/you$ scp local_directory/file user@host:remote_directory/file

So we could use:

scp /home/f00/myfile.html f00@remote.linux:/var/www/site/myfile.html

Copy a file from the remote server

Here a file will be coppied from the server to your local box. This is simple, the command is just flipped:

you@f00:/home/you$ scp user@host:remote_directory/file local_directory/file

What it looks like

The first time you make SSH (and thus when you use SCP) connections to a host it will try to protect you from a man-in-the-middle attack. It will ask if the fingerprint matches what it's supposed to be. Other connections to the host, as long as the fingerprint matches, will not also ask you this question.

you@f00:/home/you$ scp myfile.html f00@remote.linux:/var/www/myfile.html
The authenticity of host 'remote.linux (192.168.1.50)' can't be established.
RSA key fingerprint is ma:f9:31:3c:1d:37:0a:ca:68:40:z1:bf:5c:c2:6c:13.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'remote.linux,192.168.1.50' (RSA) to the list of known hosts.
f00@remote.linux's password:
myfile.txt 100% |*****************************| 250 00:01

Multiple files: directory transfer

You will find use of being able to transfer a few files all together. To accomplish this you can copy a whole directory and its contents to or from a remote server. To accomplish this we need to point to directories and add the -r (recursive) flag to the scp command. This will transfer /remote_directory/example/ and its contents to /local_directory/example/:

you@f00:/home/you$ scp -r user@host:/remote_directory/example/ /local_directory/example

Pretty GUI clients

If you've never FTP'd from the command line and stuck only to the graphical clients you'll not fancy the above command line style transferring. Fortunately, there are some widely-used applications that will bring ease to the transfer. They are all self-explanatory in their use, and more information can be found at their sites.

Windows & Macintosh

The most popular client for Windows is WinSCP. You can learn about it and download from: http://winscp.sourceforge.net/eng/.

A popular tool for Apple systems is Fugu. It includes SFTP support: http://rsug.itd.umich.edu/software/fugu/.

TI-83 Plus Black Scholes (915)

Plug n play / 2009-06-16

A sloppy implementation of Black Scholes on the TI-83 Plus. Read.

Getting C# and mySQL to play together (1188)

with C# / mySQL connector / 2008-01-28

For that project where using MS SQL isn't going to cut it. Read.

Anatomy of a Major League Baseball tryout (2163)

"Ohhh. Let me see that." / 2007-03-12

For the most part, we took it seriously. Read.

Ubuntu 6.06 LTS (Dapper Drake) on Acer Travelmate C110 (13688)

It's thin, it's light. It's a tablet. / 2006-10-18

There's nothing cooler than a really small machine running linux. This is a collection of notes from the install, setup, and tweaking of the system running Ubuntu 6.06 LTS (Dapper Drake). It's probably a little over verbose. Read.

Laptop Advice (1760)

Thinkpads vs Dell vs HPQ vs The World / 2006-05-25

Hey Mike Sklut, you're a computer nerd, what kind of laptop should I get? Read.

Caesar Salad (1736)

How it's done / 2006-01-22

The Grossi Caesar salad. Read.

Manually mapping a Windows key on a Thinkpad (2874)

Editing with the Windows registry / 2005-08-12

Thinkpad - for players. But what about a Windows key? Read.

Searching for the perfect spyware remover (3186)

A look at four highly regarded anti-spyware tools and their effectiveness. / 2004-07-28

For when you already have spyware and want it removed ASAP. A good starting point. Read.

Using SCP (3412)

Command line and GUI clients / 2004-03-14

FTP may no longer be suitable for your file transferring needs. Here's the basics to SCP and where you can find some nifty GUI clients. Read.

Review: Jens of Sweden MP-110 (2581)

Just a review / 2004-03-13

A short review of the Jens of Sweden MP110 mp3 player. Read.

Pour vous, Yaniv: rss_feed

On some mobile device? Try this.

vafrous.com: blog / articles / projects

©2008 vafrous.com, Mike Sklut / v0.4a / validate

\Va"frous\, a. [L. vafer.] Crafty; cunning; sly; as, vafrous tricks.