浪里个浪的博客

好好学习 天天向上


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 网站

  • 搜索

设置 SSH key

发表于 2019-09-21 更新于 2019-09-23 分类于 技术 阅读次数:

因为重装了系统的缘故,一些以前的设置没法找了,参照官网,重新设置一下本地的 SSH key。

以下文章源自 github 官网,个人做了一些精简。

注意:$符号是需要输入的命令,>是输入命令之后的一些显示结果

Generating a new SSH key and adding it to the ssh-agent

After you’ve checked for existing SSH keys, you can generate a new SSH key to use for authentication, then add it to the ssh-agent.

Generating a new SSH key

  1. Open Git Bash.

    1
    $ cd ~/.ssh
  2. Paste the text below, substituting in your GitHub email address.

    1
    $ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  3. When you’re prompted to “Enter a file in which to save the key,” press Enter. This accepts the default file location.

    1
    > Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]
  4. At the prompt, type a secure passphrase, press Enter.

    1
    2
    > Enter passphrase (empty for no passphrase): [Type a passphrase]
    > Enter same passphrase again: [Type passphrase again]

Adding your SSH key to the ssh-agent

  1. Ensure the ssh-agent is running:

    1
    2
    $ eval $(ssh-agent -s)
    > Agent pid 59566
  2. Add your SSH private key to the ssh-agent.

    1
    $ ssh-add ~/.ssh/id_rsa

Checking for existing SSH keys

Before you generate an SSH key, you can check to see if you have any existing SSH keys.

  1. Open Git Bash.

    1
    $ cd ~/.ssh
  2. Enter ls to see if existing SSH keys are present:

    1
    2
    $ ls
    > id_rsa id-rsa.pub //SSH keys are existing.

Adding a new SSH key to your GitHub account

To configure your GitHub account to use your new (or existing) SSH key, you’ll also need to add it to your GitHub account.

  1. Copy the SSH key to your clipboard.

    1
    $ clip < ~/.ssh/id_rsa.pub
  2. In the upper-right corner of any page, click your profile photo, then click Settings.

  1. In the user settings sidebar, click SSH and GPG keys.

  2. Click New SSH key or Add SSH key.

  3. In the “Title” field, add a descriptive label for the new key. For example, if you’re using a personal Mac, you might call this key “Personal MacBook Air”.

  1. Paste your key into the “Key” field.

  2. Click Add SSH key.

  3. If prompted, confirm your GitHub password.


参考连接:

  1. Generating a new SSH key and adding it to the ssh-agent
  2. Checking for existing SSH keys
  3. Adding a new SSH key to your GitHub account
相关文章
  • 在线上传文件夹或文件到Github
  • 如何在Github上查找好的开源项目
  • Hexo搭建教程
---------Thanks for your attention---------
浪里个浪 支付宝

支付宝

  • 本文作者: 浪里个浪
  • 本文链接: http://kevin-okay.github.io/2019/09/21/设置SSH-key/
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
git github
正则表达式
修改VSCode的默认终端为git-bash
  • 文章目录
  • 站点概览
浪里个浪

浪里个浪

世界那么大,我想去看看!
20 日志
1 分类
17 标签
RSS
Creative Commons
友情链接
  • NexT_Doc
  • NexT_Theme
  • FontAwesome1
  • FontAwesome2
  • 廖雪峰
  • 博客园
  1. 1. Generating a new SSH key and adding it to the ssh-agent
    1. 1.1. Generating a new SSH key
    2. 1.2. Adding your SSH key to the ssh-agent
  2. 2. Checking for existing SSH keys
  3. 3. Adding a new SSH key to your GitHub account
© 2019 kevin wang | 13k
由 Hexo 强力驱动 v3.9.0
|
主题 – NexT.Gemini v7.3.0
|
0%