SSH is a software package that enables secure system administration and file transfers over insecure networks. It is used in nearly every data center, in every larger enterprise.
The SSH protocol uses encryption to secure the connection between a client and a server. All user authentication, commands, output, and file transfers are encrypted to protect against attacks in the network.
This section contains links topics around using, configuring, and administering SSH.
Command line options sshd - The SSH server on Unix/Linux sshd_config - Server configuration file on Unix/Linux ssh_config - Client configuration file on Unix/Linux SSH port, and how it got that number
Linux typically uses the OpenSSH client. The ssh command to log into a remote machine is very simple. To log in to a remote computer called sample.ssh.com, type the following command at a shell prompt:
ssh sample.ssh.com
If this is the first time you use ssh to connect to this remote machine, you will see a message like:
The authenticity of host 'sample.ssh.com' cannot be established.
DSA key fingerprint is 04:48:30:31:b0:f3:5a:9b:01:9d:b3:a7:38:e2:b1: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 'sample.ssh.com' (DSA) to the list of known hosts.
Each server has a host key, and the above question related to verifying and saving the host key, so that next time you connect to the server, it can verify that it actually is the same server.
Once the server connection has been established, the user is authenticated. Typically, it asks for a password. For some servers, you may be required to type in a one-time password generated by a special hardware token.
Once authentication has been accepted, you will be at the shell prompt for the remote machine.
It is also possible to use a different username at the remote machine by entering the command as:
ssh alternative-username@sample.ssh.com
The above can also be expressed with the syntax:
ssh -l alternative-username sample.ssh.com
EXECUTING REMOTE COMMANDS ON THE SERVER
The ssh command is often also used to remotely execute commands on the remote machine without logging in to a shell prompt. The syntax for this is:
ssh hostname command
For example, to execute the command:
ls /tmp/doc
on host sample.ssh.com, type the following command at a shell prompt:
ssh sample.ssh.com ls /tmp/doc
After authenticating to the remote server, the contents of the remote directory will be displayed, and you will return to your local shell prompt. -x Disables X11 forwarding.
Some of the most important command-line options for the OpenSSH client are:
-1 Use protocol version 1 only.
-2 Use protocol version 2 only.
-4 Use IP4 addresses only.
-6 Use IPv6 addresses only.
-A Enable forwarding of the authentication agent connection.
-a Disable forwarding of the authentication agent connection.
-C Use data compression
-c cipher_spec Selects the cipher specification for encrypting the session.
-D [bind_address:]port Dynamic application-level port forwarding. This allocates a socket to listen to port on the local side. When a connection is made to this port, the connection is forwarded over the secure channel, and the application protocol is then used to determine where to connect to from the remote machine.
-E log_file Append debug logs to log_file instead of standard error.
-F configfile Specifies a per-user configuration file. The default for the per-user configuration file is ~/.ssh/config.
-g Allows remote hosts to connect to local forwarded ports.
-i identity_file A file from which the identity key (private key) for public key authentication is read.
-J [user@]host[:port] Connect to the target host by first making a ssh connection to the pjump host[(/iam/jump-host) and then establishing a TCP forwarding to the ultimate destination from there.
-l login_name Specifies the user to log in as on the remote machine.
-p port Port to connect to on the remote host.
-q Quiet mode.
-V Display the version number.
-v Verbose mode.
-X Enables X11 forwarding.