如何给 GitHub 添加 SSH key, 如何生成 SSH key 详细图文教程!
如何给 GitHub 添加 SSH key, 如何生成 SSH key 详细图文教程!
一、 生成 SSH key
创建一个空项目:(或使用真实 Linux 主机) PS: windows 类似(? CMD) ReadMore
https://ide.c9.io/xgqfrms/demo
打开 shell(bash), 输入:
1$ npm
install
-g git-it
生成 SSH-Key
1$
ssh
-keygen -t rsa -b 4096 -C
"username@email.com"
检查,添加 ssh-key 到,linux client:
12$
eval
"$(ssh-agent -s)"
$
ssh
-add ~/.
ssh
/id_rsa
复制 ssh-key public 到 剪切板:
1$ clip < ~/.
ssh
/id_rsa
.pub
如果不好使, 使用vim 打开,复制即可!
1234$
cd
/home/ubuntu/
.
ssh
/
<p>$
ls
-l<
/p
>
<p>$ vim id_rsa.pub<br>
<
/p
>
PS: 退出 vim 方法:
1. 点击 esc 键,进入vim命令模式 输入 :q
1
2. 点击 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.
123ssh
-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.
1Enter 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]
1$ 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".
12Enter 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:
123# start the ssh-agent in the background
$
eval
"$(ssh-agent -s)"
Agent pid 59566
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.
1$
ssh
-add ~/.
ssh
/id_rsa
refs
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/5880270.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2015-09-18 有关 Node.js, npm 和 modules 安装及使用方法的个人总结!All In One