Configuring an OpenSSH Client
To connect to an OpenSSH server from a client machine, you must have the The Logging in to a remote machine with The first time you Type 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:
You can also use the syntax The After you enter the correct password, the contents of the remote directory The The general syntax to transfer a local file to a remote system is as follows:
The To transfer the local file This will transfer the local file The general syntax to transfer a remote file to the local system is as follows:
The Multiple files can be specified as the source files. For example, to transfer the contents of the directory The openssh-clients
and openssh
packages installed on the client machine.
Using the
ssh
Commandssh
command is a secure replacement for the rlogin
, rsh
, and telnet
commands. It allows you to log in to a remote machine as well as execute commands on a remote machine.
ssh
is similar to using telnet
. To log in to a remote machine named penguin.example.net, type the following command at a shell prompt:
ssh penguin.example.net
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)?
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.
ssh
username
@penguin.example.netssh -l
.
username
penguin.example.netssh
command can be used to execute a command on the remote machine without logging in to a shell prompt. The syntax is ssh
. For example, if you want to execute the command hostname
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
/usr/share/doc
will be displayed, and you will return to your local shell prompt.Using the
scp
Commandscp
command can be used to transfer files between machines over a secure, encrypted connection. It is similar to rcp
.
scp
<localfile>
username@tohostname:<remotefile>
<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/
.
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:shadowmanshadowman
to /home/
on penguin.example.net. Alternately, you can leave off the final username
/shadowmanshadowman
in the scp
command.
scp
username@tohostname:<remotefile>
<newlocalfile>
<remotefile>
specifies the source including path, and <newlocalfile>
specifies the destination including path.
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/Using the
sftp
Commandsftp
utility can be used to open a secure, interactive FTP session. It is similar to ftp
except that it uses a secure, encrypted connection. The general syntax is sftp
. Once authenticated, you can use a set of commands similar to those used by FTP. Refer to the username@hostname.com
sftp
man page for a list of these commands. To read the man page, execute the command man sftp
at a shell prompt. The sftp
utility is only available in OpenSSH version 2.5.0p1 and higher.