Installation guide

98 Chapter 9. OpenSSH
ssh penguin.example.net
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 as seen in the
following message:
Warning: Permanently added ’penguin.example.net’ (DSA) to the list of known hosts.
Next, you’ll 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 use ssh without
any command line options, the username that you are logged in as on the local client ma-
chine is passed to the remote machine. If you want to specify a different username, use the
following command:
ssh -l username penguin.example.net
You can also use the syntax ssh username@penguin.example.net.
The ssh command can be used to execute a command on the remote machine without log-
ging in to a shell prompt. The syntax is ssh hostname command. 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 /usr/share/doc will be displayed,
and you will return to your shell prompt.
9.3.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 scp localfile
username@tohostname:/newfilename. The localfile specifies the source, and the
group of username@tohostname:/newfilename specifies the destination.
To transfer the local file shadowman to your account on penguin.example.net, type the fol-
lowing at a shell prompt (replace username with your username):
scp shadowman username@penguin.example.net:/home/username
This will transfer the local file shadowman to /home/username/shadowman on
penguin.example.net.
The general syntax to transfer a remote file to the local system is scp
username@tohostname:/remotefile /newlocalfile. The remotefile specifies the
source, and newlocalfile specifies the destination.
Multiple files can be specified as the source files. For example, to transfer the contents of
the directory /downloads to an existing directory called uploads on the remote machine
penguin.example.net, type the following at a shell prompt:
scp /downloads/* username@penguin.example.net:/uploads/