markdown 将SSH密钥添加到服务器

Posted

tags:

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

**Step 1: Check for SSH Keys**

`ls -al ~/.ssh`  

_# Lists all the files in your .ssh directory, if they exist
Generating public/private rsa key pair_

**Step 2: Generate a new SSH key**

`ssh-keygen -t rsa -b 4096 -C "email@email.com"`

_# Creates a new ssh key, using the provided domain username and computer name as a label
Generating public/private rsa key pair._

You’ll be asked to enter a passphrase, or simply press Enter to not enter a passphrase:  
` Enter passphrase (empty for no passphrase):`  
`Enter same passphrase again:`

After you enter a passphrase (or just press Enter twice), review the fingerprint, or ‘id’ of your SSH key:

`Your identification has been saved in /Users/username/.ssh/id_rsa.`  
`Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
`  
`The key fingerprint is:`  
`nss2VhNB0Y62VIToM+/qYe3HS4TPXmrhuBxjUz4l/I8= your@email.com`


**Step 3: Add your key to the ssh-agent**

`start the ssh-agent in the background`  
`eval $(ssh-agent -s)`

If you are using Git Bash, turn on the ssh-agent with command shown below instead:

_start the ssh-agent in the background_

Then, add your SSH key to the ssh-agent:

`ssh-add ~/.ssh/id_rsa`

**Step 4: Add your SSH key to the server**

`cat ~/.ssh/id_rsa.pub | ssh username@server.address.com 'cat >> ~/.ssh/authorized_keys'`

以上是关于markdown 将SSH密钥添加到服务器的主要内容,如果未能解决你的问题,请参考以下文章

将证书添加到ssh-agent以获取已在代理中的密钥

markdown 将SSH密钥密码导入Keychain

markdown SSH Config文件多个服务器dengan多个密钥

从变量添加 SSH 密钥

我们可以跳过关于“将 SSH 密钥添加到 ssh-agent”的部分,而只生成密钥并添加到 GitHub 吗?

如何将已生成的 SSH 密钥添加到 git bash?