Introduction to SSH and SSH Keys

What is SSH?

SSH, or Secure Shell is an encrypted network protocol, to securely connect to another computer over a network. It can be used to execute commands on a remote machine, and also to copy or move files from one machine to another.

Using ssh on the command line

The command to connect to a remote machine is ssh. E.g.
$ ssh username@hostname

Copying files

Files can be copied using SCP (secure copy) e.g.
$ scp local_file username@hostname:destination_directory
or SFTP (SSH File Transfer Protocol).

SSH Keys

SSH Keys provide a more secure way to log in to a remote machine than using password authentication. To do this you create an SSH identity, which consists of a public-private key pair. A public key and a private key are generated on the client machine (e.g. your computer). Each key consists of a long string of characters, stored in a file such as id_rsa / You then copy the public key to the remote machine that you wish to log in to. When you connect to the remote machine, ssh uses the two keys to authenticate.

What is RSA?

You may notice the terms SSH Keys and RSA keys being used interchangeably. RSA is simply the name of an algorithm for encryption (named after Rivest-Shamir-Adleman). An alternative encryption algorithm is DSA (Digital Signature Algorithm), but that is no longer recommended.

How to generate and use SSH Keys

There are many good resources that explain how to generate and use SSH keys.
Here’s a couple of good explanations:
Digital Ocean – How to set up SSH Keys (easy to follow)
Ubuntu – SSH Keys (more detailed)

If you are connecting to a provided service they most likely have a specific guide. Eg.
GithubBitbucket, Amazon EC2 etc.

Further Reading

If you are interested in how the public and private keys work together, read about public-key cryptography.