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.
|Free Today: September Issue of Linux Journal (Retail value: $5.99)||Sep 27, 2016|
|nginx||Sep 27, 2016|
|Epiq Solutions' Sidekiq M.2||Sep 26, 2016|
|Nativ Disc||Sep 23, 2016|
|Android Browser Security--What You Haven't Been Told||Sep 22, 2016|
|The Many Paths to a Solution||Sep 21, 2016|
- Android Browser Security--What You Haven't Been Told
- Readers' Choice Awards 2013
- Epiq Solutions' Sidekiq M.2
- Nativ Disc
- The Many Paths to a Solution
- Synopsys' Coverity
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Returning Values from Bash Functions
- Securing the Programmer
Pick up any e-commerce web or mobile app today, and you’ll be holding a mashup of interconnected applications and services from a variety of different providers. For instance, when you connect to Amazon’s e-commerce app, cookies, tags and pixels that are monitored by solutions like Exact Target, BazaarVoice, Bing, Shopzilla, Liveramp and Google Tag Manager track every action you take. You’re presented with special offers and coupons based on your viewing and buying patterns. If you find something you want for your birthday, a third party manages your wish list, which you can share through multiple social- media outlets or email to a friend. When you select something to buy, you find yourself presented with similar items as kind suggestions. And when you finally check out, you’re offered the ability to pay with promo codes, gifts cards, PayPal or a variety of credit cards.Get the Guide