> For the complete documentation index, see [llms.txt](https://gleek-dan.gitbook.io/dev-info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gleek-dan.gitbook.io/dev-info/git/ssh.md).

# SSH

Information about SSH.

SSH can be a little tricky. Below I have the various things I have come across to help me out. Most commands currently are for Mac, once I mess with Windows more I will update.

## Resources

* Traversy Media Video
  * <https://youtu.be/hQWRp-FdTpc>
* GitLab Docs
  * <https://docs.gitlab.com/ee/ssh/README.html>
* GitHub Docs
  * <https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh>

## SSH version installed on your system

```
$ ssh -V
```

## Create an SSH Key

Run the following command and pick all the defaults to the prompts.  This tutorial doesn't explain how to use passphrases.

```
$ ssh-keygen
```

{% hint style="info" %}
Be mindful the command above is a super basic way.  GitLab mentioned the following options at the end of the ssh-keygen command.  See the picture below or visit the [GitLab Docs](https://docs.gitlab.com/ee/ssh/README.html#generate-an-ssh-key-pair)
{% endhint %}

![](https://3236140665-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MV2S4YFWCRrOUTBDd1K%2F-MaCVrnUem_tYyca1Jo7%2F-MaC_9GGSFtazL1XH632%2Fgenerate-ssh-key.png?alt=media\&token=0e13123e-36fc-416d-8cc4-b02818b9efa1)

## Add SSH Key To GitHub or GitLab

* GitHub
  * <https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account>
* GitLab
  * <https://docs.gitlab.com/ee/ssh/README.html#add-an-ssh-key-to-your-gitlab-account>

## Test SSH Connection

The following commands should say Hello or Welcome followed by your username if you set everything up correctly.  Learn more at the [GitLab Docs](https://docs.gitlab.com/ee/ssh/README.html#verify-that-you-can-connect) or [GitHub Docs](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/testing-your-ssh-connection).

```
$ ssh -T git@github.com
$ ssh -T git@gitlab.com
```

## Are you still getting Permission Denied?

{% hint style="info" %}
Make sure you are in your root when running this command.  Also, be mindful you will replace SSH\_FILENAME with your filename.
{% endhint %}

```
$ ssh-add ~/.ssh/SSH_FILENAME
```
