Using the scp Command
The first time you ssh to a remote machine, you will see a message similar to the following:
The authenticity of host 'penguin.example.net' can't be established.
DSA key fingerprint is 94:68:3a:3a:bc:f3:9a:9b:01:5d:b3:07:38:e2:11:0c.
Are you sure you want to continue connecting (yes/no)?
Type yes to continue. This will add the server to your list of known hosts (~/.ssh/known_hosts) as
seen in the following message:
Warning: Permanently added 'penguin.example.net' (RSA) to the list of known hosts.
Next, you will see a prompt asking for your password for the remote machine. After entering your
password, you will be at a shell prompt for the remote machine. If you do not specify a username the
username that you are logged in as on the local client machine is passed to the remote machine. If
you want to specify a different username, use the following command:
ssh username@penguin.example.net
You can also use the syntax ssh -l username penguin.example.net.
The ssh command can be used to execute a command on the remote machine without logging in
to a shell prompt. The syntax is ssh hostnamecommand. For example, if you want to execute the
command ls /usr/share/doc on the remote machine penguin.example.net, type the following
command at a shell prompt:
ssh penguin.example.net ls /usr/share/doc
After you enter the correct password, the contents of the remote directory /usr/share/doc will be
displayed, and you will return to your local shell prompt.
18.6.2. Using the scp Command
The scp command can be used to transfer files between machines over a secure, encrypted
connection. It is similar to rcp.
The general syntax to transfer a local file to a remote system is as follows:
scp <localfile> username@tohostname:<remotefile>
The <localfile> specifies the source including path to the file, such as /var/log/maillog. The
<remotefile> specifies the destination, which can be a new filename such as /tmp/hostname-
maillog. For the remote system, if you do not have a preceding /, the path will be relative to the
home directory of username, typically /home/username/.
To transfer the local file shadowman to the home directory of your account on penguin.example.net,
type the following at a shell prompt (replace username with your username):
scp shadowman username@penguin.example.net:shadowman
231
Need help?
Do you have a question about the ENTERPRISE LINUX 5 - DEPLOYMENT and is the answer not in the manual?
Questions and answers