# 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 %}

![](/files/-MaC_9GGSFtazL1XH632)

## 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gleek-dan.gitbook.io/dev-info/git/ssh.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
