BreadCrumbs: Secure Copy (SCP)

Secure Copy (SCP)

From Luke Jackson

(Difference between revisions)
Jump to: navigation, search
Revision as of 20:36, 30 November 2006 (edit)
Ljackson (Talk | contribs)
(External Links)
← Previous diff
Current revision (14:57, 18 October 2015) (edit)
Ljackson (Talk | contribs)
(Escaping Spaces)
 
Line 15: Line 15:
scp scp
 +
 +=== Mac OS X (GUI) ===
 +
 +There is no built-in Graphical User Interface (GUI) client for '''scp''' on Mac OS X.
 +
 +'''Requirements'''
 +
 +* Mac OS X
 +* Fugu GUI SCP Client - [http://rsug.itd.umich.edu/software/fugu/ Download]
 +
 +'''Install Fugu'''
 +
 +[[Image:fugu_connect_info.png|frame|right|Fugu Screenshot]]
 +
 +Installing .DMG Applications on Mac OS X is very simple. Simply drag the icon from the .DMG image window into your Applications folder and you are done.
 +
 +'''Connecting'''
 +
 +Once you have installed Fugu simply enter the information into the fields provided.
 +
 +* '''Connect''': Server Address
 +* '''User Name''': Login ID
 +* '''Port''': SCP port number (Default port 22)
 +* '''Directory''': Starting directory (Optional)
 +
 +After you click connect Fugu will attempt to authenticate with the server based on the servers installed mechanisms. This simply means that if you are not using [[Public Key Authentication]] it will fall back to password authentication and prompt you for your password.
=== Windows XP === === Windows XP ===
-While not native to Windows, there is a Windows program that acts the same called '''pscp''', which is created by the same people who distribute putty "[http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html| www.chiark.greenend.org.uk]".+While not native to Windows, there is a Windows program that acts the same called '''pscp''', which is created by the same people who distribute [[Terminal Windows XP|PuTTY]] - "[http://www.putty.nl/download.html www.putty.nl]".
To install on Windows, download and save ''pscp.exe'' to ''C:\WINDOWS\''. This way you can type '''pscp''' in any folder and still have access to it. '''If you are using pscp, please remember throughout this guide to replace ''scp'' with ''pscp''!''' To install on Windows, download and save ''pscp.exe'' to ''C:\WINDOWS\''. This way you can type '''pscp''' in any folder and still have access to it. '''If you are using pscp, please remember throughout this guide to replace ''scp'' with ''pscp''!'''
Line 26: Line 52:
* Does not transfer as quickly as scp. * Does not transfer as quickly as scp.
* Does not support spaces of any type in file names (quotations won't save you this time!) * Does not support spaces of any type in file names (quotations won't save you this time!)
 +
 +=== Windows XP (GUI) ===
 +
 +[[Image:Winscp_connect.JPG|thumb|400px|WinSCP Screenshot]]
 +
 +There is no built-in Graphical User Interface (GUI) client for '''scp''' on Windows XP.
 +
 +'''Requirements'''
 +
 +* Windows XP
 +* WinSCP Client - [http://winscp.net/eng/download.php Download]
 +
 +'''Install WinSCP'''
 +
 +Once the executable is finished downloading simple follow the dialog boxes to install the software on your computer.
 +
 +'''Connecting'''
 +
 +Once you have installed WinSCP simply enter the information into the fields provided.
 +
 +* '''Host name''': Server Address
 +* '''Port''': SCP port number (Default port 22)
 +* '''User Name''': Login ID
 +* '''Password''': Password
 +* '''Private key file''': Path to your private key (Optional)
 +* '''SFTP, SFTP (SCP Fallback), SCP'''
 +
 +Once you click '''Login''' WinSCP will authenticate with the server and bring up an window displaying the current files on the server.
== Examples == == Examples ==
Line 68: Line 122:
scp -r user@server.com:/path/to/directory /new/local/location/ scp -r user@server.com:/path/to/directory /new/local/location/
-=== Escaping Spaces ===+=== Escaping Spaces with (~) Tilda Support ===
Below is an example of how to work with spaces in directory structure: Below is an example of how to work with spaces in directory structure:
scp user@server.ext:'/home/samba/Service\ Deliver/System\ Admin/file\ name.sxw' . scp user@server.ext:'/home/samba/Service\ Deliver/System\ Admin/file\ name.sxw' .
 +
 + scp user@host:"'filename with spaces'" destination
 +
 + rsync --bwlimit=2048 --partial --progress -vvrae 'ssh' user@server:~/"'files/Name - With A lot Of spaces'" .
 +
 +== Public Key Authentication ==
 +
 +If you have many different servers that you have to connect to on a daily basis it may be more effective for you to use [[Public Key Authentication]]. With this feature enabled you are able to securely authenticate to servers with out typing in a password. Unfortunately in order to use it you will have to configure you server and client to support it.
== See Also == == See Also ==
-* [[Dedicated Bittorrent Server]] +* [[Public Key Authentication]] - Use SCP without having to deal with passwords.
== External Links == == External Links ==
-* [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html www.chiark.greenend.org.uk]+* [http://www.putty.nl/download.html www.putty.nl]
[[Category:Mac OS X]] [[Category:Mac OS X]]
[[Category:Linux]] [[Category:Linux]]
[[Category:Windows XP]] [[Category:Windows XP]]

Current revision

Contents

Summary

Secure Copy is the quickest, most effect way to transfer data from one machine to another. It's speeds surpass that of SFTP by far, but still are encyrpted with a rock solid algorithm. It may seem a little tricky at first, but it can prove to be quite useful, especially if you can utilize bash scripting.

Requirements

Linux

Secure Copy comes standard and can be executed by the command below:

scp

Mac OS X

Secure Copy comes standard and can be executed by the command below:

scp

Mac OS X (GUI)

There is no built-in Graphical User Interface (GUI) client for scp on Mac OS X.

Requirements

  • Mac OS X
  • Fugu GUI SCP Client - Download

Install Fugu

Fugu Screenshot
Fugu Screenshot

Installing .DMG Applications on Mac OS X is very simple. Simply drag the icon from the .DMG image window into your Applications folder and you are done.

Connecting

Once you have installed Fugu simply enter the information into the fields provided.

  • Connect: Server Address
  • User Name: Login ID
  • Port: SCP port number (Default port 22)
  • Directory: Starting directory (Optional)

After you click connect Fugu will attempt to authenticate with the server based on the servers installed mechanisms. This simply means that if you are not using Public Key Authentication it will fall back to password authentication and prompt you for your password.

Windows XP

While not native to Windows, there is a Windows program that acts the same called pscp, which is created by the same people who distribute PuTTY - "www.putty.nl".

To install on Windows, download and save pscp.exe to C:\WINDOWS\. This way you can type pscp in any folder and still have access to it. If you are using pscp, please remember throughout this guide to replace scp with pscp!

Some drawbacks to the windows version of pscp:

  • Does not support files over 2GB. It doesn't tell you, either, it just corrupts the file.
  • Does not transfer as quickly as scp.
  • Does not support spaces of any type in file names (quotations won't save you this time!)

Windows XP (GUI)

WinSCP Screenshot
Enlarge
WinSCP Screenshot

There is no built-in Graphical User Interface (GUI) client for scp on Windows XP.

Requirements

Install WinSCP

Once the executable is finished downloading simple follow the dialog boxes to install the software on your computer.

Connecting

Once you have installed WinSCP simply enter the information into the fields provided.

  • Host name: Server Address
  • Port: SCP port number (Default port 22)
  • User Name: Login ID
  • Password: Password
  • Private key file: Path to your private key (Optional)
  • SFTP, SFTP (SCP Fallback), SCP

Once you click Login WinSCP will authenticate with the server and bring up an window displaying the current files on the server.

Examples

Uploading

To put a file in your home directory on the server:

scp local_file.txt user@server.com:

To send a file to a specific directory:

scp local_file.txt user@server.com:/directory/to/folder/you/want/it/to/go/

To put the file on the server in a subfolder of your home dir named "downloads", the command would be:

scp local_file.txt user@server.com:downloads/

Notice the difference between the last two. When going to a folder that does not reside within your home dir, you must start with the root directory and give a full path. When you are adding stuff to your home folder, you do NOT start with a root directory! (Root directory is the forward slash to the very left of the path.)

(The following tip does not work from pscp, ONLY scp): If your local username is the same as the remove username, you can omit your login name from the command. For instance, if your local login is jwatt and your remove login is jwatt, you can take this command:

scp local_file.mp3 jwatt@gtwy.net:music/

and simplify it, turning it into:

scp local_file.mp3 gtwy.net:music/

This doesn't work on Windows because local Windows users are different than linux users.

To upload a directory to a webserver, you use the recursive switch -r:

scp -r local_folder/ user@server.com:/path/to/wherever/

After uploading, the folder location will be:

/path/to/wherever/local_folder/

Downloading

To download the file "serials.txt" from your remote home dir to the local computer:

scp user@server.com:serials.txt .

To download the remote file "something" using it's full path to your local computer:

scp user@server.com:/path/to/file/something.txt .

Now the tricky part: using the recursive switch (-r) to download a whole folder to your local computer. The issue you may have is that you DO NOT place a trailing forward slash after the directory name. For instance, this command will NOT work (notice the bold forward slash):

scp -r user@server.com:/path/to/directory/ .

This will give you a message saying the server is trying to write to the parent directory. REMOVE the last foward slash on the path and try again. The next command is CORRECT:

scp -r user@server.com:/path/to/directory .

I have been using a period when talking about downloading so far. Reason: this brings the file into the directory you are currently in. If you wish to take the last command and download it to somewhere else, the command would be:

scp -r user@server.com:/path/to/directory /new/local/location/

Escaping Spaces with (~) Tilda Support

Below is an example of how to work with spaces in directory structure:

scp user@server.ext:'/home/samba/Service\ Deliver/System\ Admin/file\ name.sxw' .
scp user@host:"'filename with spaces'" destination

rsync --bwlimit=2048 --partial --progress -vvrae 'ssh' user@server:~/"'files/Name - With A lot Of spaces'" .

Public Key Authentication

If you have many different servers that you have to connect to on a daily basis it may be more effective for you to use Public Key Authentication. With this feature enabled you are able to securely authenticate to servers with out typing in a password. Unfortunately in order to use it you will have to configure you server and client to support it.

See Also

External Links