Skip to content

Latest commit

 

History

History
56 lines (36 loc) · 1.47 KB

README.md

File metadata and controls

56 lines (36 loc) · 1.47 KB

Using SSH Keys

SSH keys are a form of identification that the Secure Shell (SSH) protocol uses to securely connect to remote servers. Here's how to use SSH keys.

Generating SSH Keys

  1. Open a terminal.

  2. Run the following command to generate a new SSH key:

    ssh-keygen -t rsa -b 4096 -C "[email protected]"

Replace "[email protected]" with your email address.

  1. When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.

  2. At the prompt, type a secure passphrase.

Adding Your SSH Key to the ssh-agent

  1. Start the ssh-agent in the background:

    eval "$(ssh-agent -s)"
  2. Add your SSH private key to the ssh-agent:

    ssh-add ~/.ssh/id_rsa

Adding Your SSH Key to Your Account on the Server

  1. Copy your SSH public key to your clipboard:

    clip < ~/.ssh/id_rsa.pub

On Linux, you can use xclip:

```bash
xclip -sel clip < ~/.ssh/id_rsa.pub
```
  1. On the server you want to connect to, open the ~/.ssh/authorized_keys file in a text editor and paste your public key on a new line.

Connecting to the Server

You can now connect to the server with:

```bash
ssh user@hostname
```

Replace user with your username on the server and hostname with the hostname of the server. Because you've added your SSH key to the ssh-agent, you shouldn't have to enter your passphrase every time you connect.