markdown SSH密钥管理。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown SSH密钥管理。相关的知识,希望对你有一定的参考价值。

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`

以上是关于markdown SSH密钥管理。的主要内容,如果未能解决你的问题,请参考以下文章

markdown 更好的SSH授权密钥管理

markdown SSH使用原密钥生成新的无密码密钥

markdown SSH授权密钥

markdown SSH密钥添加到系统中

markdown 如何备份和恢复ssh密钥

markdown 创建新的SSH密钥