https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
https://gitlab.com/help/ssh/README#generating-a-new-ssh-key-pair
**Generate SSH Key for Git**
1. Open Powershell;
2. List All Keys
`ls ~/.ssh`
3. Delete the id_rsa Files
`rm -f ~/.ssh/id_rsa*`
4. open Git UI > Help > Show SSH Key click "Generate Key" button or do
`$ ssh-keygen -t rsa -b 4096 -C "sarpay@gmail.com"`
---
If you want to **change the password** of your SSH key pair, you can use:
```
$ ssh-keygen -p <keyname>.
```
---
**To copy your public SSH key to the clipboard, use the appropriate code below:**
**macOS**
```
$ pbcopy < ~/.ssh/id_rsa.pub (macOS)
```
**Windows Command Line**
```
$ type %userprofile%\.ssh\id_rsa.pub | clip
```
**Git Bash on Windows / Windows PowerShell**
```
$ cat ~/.ssh/id_rsa.pub | clip
```
---
**Paste the Public SSH Key to GitLab or GitHub**
contents of the *sarpay.oner/.ssh/id_rsa.pub* file.
---
**Automatically load keys into the ssh-agent and store passphrases in your keychain.**
create a file called "config" (no extension), paste the text below and
place it inside `~/.ssh/` folder.
```c#
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
```
---
**To apply the SSH key to the project folder;**
*remedies Git Permission denied (publickey)*
**Git BASH**
Start ssh-agent in order to use ssh-add
```
$ eval "ssh-agent -s"
-- or --
$ eval "$(ssh-agent -s)"
```
**Common**
adds the key to the project folder
```
$ ssh-add ~/.ssh/id_rsa
-- or --
-- use this so you don't have to add everytime.
$ ssh-add -K ~/.ssh/id_rsa
```
The -K option is in Apple's standard version of ssh-add,
which stores the passphrase in your keychain for you when you add an ssh key
to the ssh-agent.
If you have installed a different version of ssh-add,
it may lack support for -K. In this case use the one below:
`$ /usr/bin/ssh-add -K ~/.ssh/id_rsa`
---
**Start VS Code**
`$ code`