如何给 GitHub 添加 SSH key, 如何生成 SSH key 详细图文教程!

如何给 GitHub 添加  SSH key, 如何生成  SSH key 详细图文教程!

一、 生成  SSH key

https://ide.c9.io/xgqfrms/

创建一个空项目:(或使用真实 Linux 主机) PS: windows 类似(? CMDReadMore

https://ide.c9.io/xgqfrms/demo

打开 shell(bash), 输入:

$ npm install -g git-it

如何给 GitHub 添加  SSH key, 如何生成  SSH key 详细图文教程!

生成 SSH-Key

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

如何给 GitHub 添加  SSH key, 如何生成  SSH key 详细图文教程!

检查,添加 ssh-key 到,linux client:

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa

如何给 GitHub 添加  SSH key, 如何生成  SSH key 详细图文教程!

复制 ssh-key public 到 剪切板:

$ clip < ~/.ssh/id_rsa.pub

如果不好使, 使用vim 打开,复制即可!

$ cd /home/ubuntu/.ssh/

$ ls -l

$ vim id_rsa.pub

如何给 GitHub 添加  SSH key, 如何生成  SSH key 详细图文教程!

PS: 退出 vim 方法:

1. 点击 esc 键,进入vim命令模式 输入 :q

:q

2. 点击 Enter 即可退出!

NEW:   after add ssh key ,you should close the terminal & restart a new terminal!

二、 给 GitHub 添加  SSH key

1. 打开 设置>SSH and GPG Keys> New SSH key ,

2. 将复制的 id_rsa.pub 的 key 值,粘贴到 key 文本框,点击 Add SSH key 即可!

如何给 GitHub 添加  SSH key, 如何生成  SSH key 详细图文教程!

ok!

如何给 GitHub 添加  SSH key, 如何生成  SSH key 详细图文教程!

NEW:   after add ssh key ,you should close the terminal & restart a new terminal!

1

Checking for existing SSH keys

https://help.github.com/articles/checking-for-existing-ssh-keys/#platform-linux

Adding a new SSH key to your GitHub account

https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

1

Multi Account for GitHub!

new path

如何给 GitHub 添加  SSH key, 如何生成  SSH key 详细图文教程!

创建 config,配置 multi account for GitHub!
touch config
编辑 config
vim config

如何给 GitHub 添加  SSH key, 如何生成  SSH key 详细图文教程!

NEW:   after add ssh key ,you should close the terminal & restart a new terminal!

1

1

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 Terminal.

  2. Paste the text below, substituting in your GitHub email address.

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    # Creates a new ssh key, using the provided email as a label
    Generating public/private rsa key pair.
  3. When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.

    Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
    

    using new path in case of override your other SSH-keys
     Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]

    如何给 GitHub 添加  SSH key, 如何生成  SSH key 详细图文教程!

    $ Enter a file in which to save the key (/Users/you/.ssh/id_rsa): /Users/you/.ssh/id_rsa_github [Type a passphrase]
    
  4. At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".

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

Adding your SSH key to the ssh-agent

Before adding a new SSH key to the ssh-agent, you should have checked for existing SSH keys andgenerated a new SSH key.

  1. Ensure ssh-agent is enabled:

    # start the ssh-agent in the background
    $ eval "$(ssh-agent -s)"
    Agent pid 59566
  2. Add your SSH key to the ssh-agent. If you used an existing SSH key rather than generating a new SSH key, you'll need to replace id_rsa in the command with the name of your existing private key file.

    $ ssh-add ~/.ssh/id_rsa
    
  3. Add the SSH key to your GitHub account.

1

 
上一篇:MySQL 5.7.20绿色版安装详细图文教程


下一篇:基于visual Studio2013解决算法导论之004随机排列数组