在Linux中配置ssh密钥,在Git中使用SSH协议访问Github
来源:互联网 发布:node v7.0.0 x64.msi 编辑:程序博客网 时间:2024/05/22 00:15
在Linux中配置ssh密钥,在Git中使用SSH协议访问Github,使用 SSH 协议, 您可以连接并验证远程服务器和服务。在每次访问时连接到 GitHub 而不提供用户名或密码。
第一步:检查是否存在SSH秘钥
- Enter
ls -al ~/.ssh
to see if existing SSH keys are present - 如果显示
ls: 无法访问/home/qy/.ssh: 没有那个文件或目录
表示目录不存在,ssh不存在
第二步:生成 SSH key.
1.输入指令:
$ ssh-keygen -t rsa -C "your_email@example.com"
注意:字母C要大写,如下图所示:
2、生成密钥
Enter file in which to save the key (/home/qy/.ssh/id_rsa): 【按回车】Enter passphrase (empty for no passphrase): 【输入密码】Enter same passphrase again: 【再次输入密码】
如上图所示,到此为止,已经生成私钥和公钥,存储路径如下所示:
Your identification has been saved in /home/qy/.ssh/id_rsa.Your public key has been saved in /home/qy/.ssh/id_rsa.pub.
第三步:添加 SSH key到 ssh-agent
1、首先确保ssh-agent 工作
$ eval $(ssh-agent -s)Agent pid 8569
2、将 ssh 私钥添加到 ssh 代理中。如果使用不同的名称创建了密钥, 或者添加了具有不同名称的现有密钥, 请用私钥文件的名称替换该命令中的 id_rsa。
$ ssh-add ~/.ssh/id_rsaEnter passphrase for /home/qy/.ssh/id_rsa: 【输入密码】Identity added: /home/qy/.ssh/id_rsa (/home/qy/.ssh/id_rsa)
第四步:添加一个新的 SSH key到你的Github账户
1、复制 SSH key 到你的剪贴板
$ clip < ~/.ssh/id_rsa.pub# Copies the contents of the id_rsa.pub file to your clipboard.
或者直接打开~/.ssh/id_rsa.pub
文件,复制里面的内容
2、添加一个新的 SSH key到你的Github账户
登录你的github,头像处下拉框选择settings
。
进入设置页后点击侧边栏的SSH and GPG keys
按钮。
点击New SSH key
, title
可以任意填,并且将上一步骤复制的内容粘贴到这里的key输入框中
如果出现提示, 请确认您的 GitHub 密码。
第五步:确认
1、输入:
$ ssh -T git@github.com
2、显示以下内容
The authenticity of host 'github.com (192.30.255.113)' can't be established.RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.Hi Qing-Yu-1! You've successfully authenticated, but GitHub does not provide shell access.
看到下面这段说明大工告成:
Hi Qing-Yu-1! You've successfully authenticated, but GitHub does not provide shell access.
更多信息参考:
https://help.github.com/articles/connecting-to-github-with-ssh/
https://www.gitbook.com/book/bingohuang/progit2/details
阅读全文
0 0
- 在Linux中配置ssh密钥,在Git中使用SSH协议访问Github
- Git配置多ssh密钥:同时使用gitlab和github
- Git在http代理中使用ssh
- 配置 Git 和 SSH 密钥连接 Github
- log4j使用配置 在ssh中配置
- log4j使用配置 在ssh中配置
- mac中github使用.ppk密钥通过ssh协议clone代码
- GitHub在linux中的配置SSH
- github中ssh配置
- 在LoadRunner中使用SSH连接Linux
- git配置ssh密钥
- Git 配置 SSH密钥
- git使用ssh密钥
- git使用ssh密钥
- git使用ssh密钥
- git使用ssh密钥
- git使用ssh密钥
- git使用ssh密钥
- 面向比特的链路控制规程HDLC和点对点协议
- VMware发布新版vSphere6.5虚拟化平台,助力企业数字化转型
- LeetCode#740 Delete and Earn (week16)
- 数据中心管理人员预计2018年发生的变化
- LINUX下的一些小工具
- 在Linux中配置ssh密钥,在Git中使用SSH协议访问Github
- 2017最具内容价值APP榜单发布:人人都是产品经理获「年度产品技术类MVP应用」
- 新技术,新挑战,新能力:金融+AI 的产品实践
- 解决Xshell关闭vim后内容仍停留在屏幕的问题
- 写了10篇产品分析后,我似乎知道怎么做一款短视频产品了……
- 你说我是佛系运营,而我身上却有你的影子
- 写文案痛苦、写出的文案不能产生价值?这里有方法,4周炼成文案高手
- 阻塞队列入门2
- 简单搜索模板