惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 一叶浮萍

Visual Studio 2022 Net6.0 无法发现testcase, 也无法执行test case Microsoft.AspNetCore.Http.Abstractions 2.20 is deprecated 使用office365 world2016发布编辑备份你的博客 使用office365 world2016发布编辑备份你的博客 You are not late! You are not early! 在同一个服务器(同一个IP)为不同域名绑定的免费SSL证书 Vue.js Is Good, but Is It Better Than Angular or React? It was not possible to find any compatible framework version VS增加插件 Supercharger破解教程 Disconnected: No supported authentication methods available (server sent: publickey) VS 2013打开.edmx文件时报类型转换异常 Echarts ecomfe 触摸屏 touch 在IE10下无法显示悬浮框 64位系统里注册32位软件 System.Data.Dbtype转换为System.Data.SqlDbType Bonobo Git Server (Simple git server for Windows.) 测试备忘 TortoiseGit bonobo gitserver记住帐号密码 TortoiseGit bonobo gitserver记住帐号密码 TITLE: BizTalk Server 2013 Administration Console 应用程序-特定 权限设置并未向在应用程序容器 不可用 SID (不可用)中运行的地址 LocalHost (使用 LRPC) 中的用户
Git使用ssh key
一叶浮萍 · 2017-02-16 · via 博客园 - 一叶浮萍

生成ssh key步骤

这里以配置githubssh key为例:

1. 配置git用户名和邮箱

git config user.name "用户名"

git config user.email "邮箱"

config后加上 --global 即可全局设置用户名和邮箱。

2. 生成ssh key

ssh-keygen -t rsa -C "邮箱"

然后根据提示连续回车即可在~/.ssh目录下得到id_rsaid_rsa.pub两个文件,id_rsa.pub文件里存放的就是我们要使用的key

如果生成时显示~/.ssh目录在奇怪的位置,那想修改位置,请直接到系统设置的用户环境变量里增加%HOME%用户环境变量即可

3. 上传keygithub

clip < ~/.ssh/id_rsa.pub

  1. 复制key到剪贴板

  2. 登录github

  3. 点击右上方的Accounting settings图标

  4. 选择 SSH key

  5. 点击 Add SSH key

也可以直接打开id_rsa.pub文件,复制其中内容,然后粘贴到github网站中,穿件SSH Key.

4. 测试是否配置成功

ssh -T git@github.com

如果配置成功,则会显示:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.

有时候未必显示成功,但github访问也是没有问题的,还需要实际下载代码上传代码(使用git@github.com)测试一下

解决本地多个ssh key问题

有的时候,不仅github使用ssh key,工作项目或者其他云平台可能也需要使用ssh key来认证,如果每次都覆盖了原来的id_rsa文件,那么之前的认证就会失效。这个问题我们可以通过在~/.ssh目录下增加config文件来解决。

下面以配置搜狐云平台的ssh key为例。

1. 第一步依然是配置git用户名和邮箱

git config user.name "用户名"

git config user.email "邮箱"

2. 生成ssh key时同时指定保存的文件名

ssh-keygen -t rsa -f ~/.ssh/id_rsa.sohu -C "email"

上面的id_rsa.sohu就是我们指定的文件名,这时~/.ssh目录下会多出id_rsa.sohuid_rsa.sohu.pub两个文件,id_rsa.sohu.pub里保存的就是我们要使用的key

3. 新增并配置config文件

添加config文件

如果config文件不存在,先添加;存在则直接修改

touch ~/.ssh/config

config文件里添加如下内容(User表示你的用户名)

Host *.cloudscape.sohu.com #对于gitlab.com,正确的配置是不能包含匹配符*的,以为 *.gitlab.com不能匹配 gitlab.com

IdentityFile ~/.ssh/id_rsa.sohu

User test #此配置可以省略

4. 上传key到云平台后台(省略)

5. 测试ssh key是否配置成功

ssh -T git@git.cloudscape.sohu.com

成功的话会显示:

Welcome to GitLab, username!

至此,本地便成功配置多个ssh key。日后如需添加,则安装上述配置生成key,并修改config文件即可。

设置SSH使用HTTPS403端口

在局域网中SSH22端口可能会被防火墙屏蔽,可以设置SSH使用HTTPS403端口。

测试HTTPS端口是否可用

1
2
3

$ ssh -T -p 443 git@ssh.github.com
Hi username! You've successfully authenticated, but GitHub does not
provide shell access.


编辑SSH配置文件 ~/.ssh/config 如下:

1
2
3

Host github.com
Hostname ssh.github.com
Port 443


测试是否配置成功

1
2
3

$ ssh -T git@github.com
Hi username! You've successfully authenticated, but GitHub does not
provide shell access.

一些错误

disconnected no supported authentication methods available(server sent: publickeykeyboard interae

安装Git客户端后,进行PULL时报如下错误

disconnected no supported authentication methods available(server sent: publickeykeyboard interactive)解决方案

因为TortoiseGitGit的冲突 我们需要把TortoiseGit设置改正如下。

1.找到TortoiseGit -> Settings -> Network

2.SSH client指向~\Git\bin\ssh.exe(Git安装路径下)Git2.7版本下在C:\Program Files\Git\usr\bin

然后便可正确pushpull