The 101 Uses of OpenSSH: Part I
We'll cover one more ssh topic before we adjourn for this month. The scp command, in most ways equivalent to the old rcp utility, is used to copy a file or directory from one host to another. (In fact, scp is based on rcp's source code.) In case you're unfamiliar with either, they're noninteractive: each is invoked with a single command line, in which you must specify the names and paths of both of what you're copying and where you want it to go.
This noninteractive quality makes scp a bit less user-friendly than ftp: like it or not, to use scp you need to read its man page (or articles like this) and memorize a few flags. But like most other command-line utilities, scp is far more useful in scripts than interactive tools tend to be. Using scp “on the fly”, though, is easy to learn. The basic syntax of the scp command is
scp [ options ] sourcefilestring destfilestring
where the source and destination file strings can either be a normal UNIX file/path string (e.g., "./docs/hello.txt", "/home/me/mydoc.txt", etc.) or a host-specific string in the format
email@example.com:path/filenameFor example, suppose you're logged into the host “crueller” and want to transfer the file “recipe” to your home directory on the remote host “kolach”. Suppose further that you've got the same user name on both systems. The session would look something like this (user input in bold):
crueller: > scp ./recipe kolach:~ mick@kolach's password: ******* recipe 100% |**************>| 13226 00:00 crueller: >After typing the scp command line, we were prompted for our password (our username, since we didn't specify one, was automatically submitted for us using the username we're logged on to crueller as). scp then copied the file over, showing us a handy progress bar as it went along. And that's it!
Suppose you're logged on to crueller as “mick” but have the username “mbauer” on kolach and wish to write the file to kolach's directory data/recipes/pastries. Then our command line would look like this:
crueller: > scp ./recipe mbauer@kolach:/data/recipies/pastries/
Now let's switch things around. Suppose we want to retrieve the file /etc/oven.conf from kolach (we're still logged in to crueller). Then our command line looks like this:
crueller: > scp mbauer@kolach:/etc/oven.conf.Get the picture? The important thing to remember is that the source must come before the destination.
Although most users use ssh and scp for simple logins and file transfers, respectively, this only scratches the surface of what ssh can do. Next month we'll examine how RSA and DSA keys can be used to make ssh transactions even more secure, how “null-passphrase” keys can allow ssh commands to be included in scripts, how to cache ssh credentials in RAM to avoid unnecessary authentication prompts and how to tunnel other TCP services through an encrypted ssh connection.
Getting Started with DevOps - Including New Data on IT Performance from Puppet Labs 2015 State of DevOps Report
August 27, 2015
12:00 PM CDT
DevOps represents a profound change from the way most IT departments have traditionally worked: from siloed teams and high-anxiety releases to everyone collaborating on uneventful and more frequent releases of higher-quality code. It doesn't matter how large or small an organization is, or even whether it's historically slow moving or risk averse — there are ways to adopt DevOps sanely, and get measurable results in just weeks.
Free to Linux Journal readers.Register Now!
|Secure Server Deployments in Hostile Territory, Part II||Jul 29, 2015|
|Hacking a Safe with Bash||Jul 28, 2015|
|KDE Reveals Plasma Mobile||Jul 28, 2015|
|Huge Package Overhaul for Debian and Ubuntu||Jul 23, 2015|
|diff -u: What's New in Kernel Development||Jul 22, 2015|
|Shashlik - a Tasty New Android Simulator||Jul 21, 2015|
- Secure Server Deployments in Hostile Territory, Part II
- Hacking a Safe with Bash
- KDE Reveals Plasma Mobile
- Huge Package Overhaul for Debian and Ubuntu
- The Controversy Behind Canonical's Intellectual Property Policy
- Home Automation with Raspberry Pi
- Shashlik - a Tasty New Android Simulator
- Embed Linux in Monitoring and Control Systems
- diff -u: What's New in Kernel Development
- General Relativity in Python