如何给 GitHub 添加 SSH key, 如何生成 SSH key 详细图文教程!
一、 生成 SSH key
创建一个空项目:(或使用真实 Linux 主机) PS: windows 类似(? CMD) ReadMore
https://ide.c9.io/xgqfrms/demo
打开 shell(bash), 输入:
$ npm install -g git-it
生成 SSH-Key
$ ssh-keygen -t rsa -b 4096 -C "username@email.com"
检查,添加 ssh-key 到,linux client:
$ eval "$(ssh-agent -s)" $ ssh-add ~/.ssh/id_rsa
复制 ssh-key public 到 剪切板:$ clip < ~/.ssh/id_rsa.pub如果不好使, 使用vim 打开,复制即可!
$ cd /home/ubuntu/.ssh/ $ ls -l $ vim id_rsa.pub
PS: 退出 vim 方法:
1. 点击 esc 键,进入vim命令模式 输入 :q
:q2. 点击 Enter 即可退出!
NEW: after add ssh key ,you should close the terminal & restart a new terminal!
二、 给 GitHub 添加 SSH key
1. 打开 设置>
Keys> New SSH key ,2. 将复制的 id_rsa.pub 的 key 值,粘贴到 key 文本框,点击 Add SSH key 即可!
ok!
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
创建 config,配置 multi account for GitHub!
touch config
编辑 config
vim config
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
Open Terminal.
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.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]
$ Enter a file in which to save the key (/Users/you/.ssh/id_rsa): /Users/you/.ssh/id_rsa_github [Type a passphrase]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.
Ensure ssh-agent is enabled:
# start the ssh-agent in the background $ eval "$(ssh-agent -s)" Agent pid 59566Add 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
1