This leads to the situation shown in Figure 2-1. The ssh command runs a client that contacts the SSH server on shell.isp.com over the Internet, asking to be logged into the remote account with username pat.[5] You can also provide user@host syntax instead of the -l option to accomplish the same thing:$ ssh -l pat shell.isp.com pat's password: ****** Last login: Mon May 24 19:32:51 1999 from quondam.nefertiti.org You have new mail. shell.isp.com>
[5]If the local and remote usernames are identical, you can omit the -l option (-l pat) and just type ssh shell.isp.com.
$ ssh pat@shell.isp.com
In this example, scp copies the file print-me on shell.isp.com over the network to a local file in your friend's account on local.university.edu, also called print-me :scp name-of-source name-of-destination
The file is transferred over an SSH-secured connection. The source and destination files may be specified not only by filename, but also by username ("pat" in our example) and hostname (shell.isp.com), indicating the location of the file on the network. Depending on your needs, various parts of the source or destination name can be omitted, and defaults values used. For example, omitting the username and the "at" sign (pat@) makes scp assume that the remote username is the same as the local one. Like ssh, scp prompts for your remote password and passes it to the SSH server for verification. If successful, scp logs into the pat account on shell.isp.com, copies your remote file print-me to the local file print-me, and logs out of shell.isp.com. The local file print-me may now be sent to a printer. The destination filename need not be the same as the remote one. For example, if you're feeling French, you could call the local file imprime-moi :$ scp pat@shell.isp.com:print-me print-me
The full syntax of scp can represent local and remote files in powerful ways, and the program also has numerous command-line options. [Section 7.5, "Secure Copy with scp"]$ scp pat@shell.isp.com:print-me imprime-moi
2. Basic Client Use | 2.3. Adding Complexity to the Example |
Copyright © 2002 O'Reilly & Associates. All rights reserved.