freeCodeCamp/guide/chinese/git/authenticate-with-github-us.../index.md

1.1 KiB
Raw Blame History

title localeTitle
How to authenticate with GitHub using SSH 如何使用SSH对GitHub进行身份验证

如何使用SSH对GitHub进行身份验证

在继续之前检查这里没有rsa文件,使用:

ls -al ~/.ssh 

如果没有要列出的内容(即: No such file or directory ),那么使用:

mkdir $HOME/.ssh 

如果那里什么也没有那么生成一个新的keygen

ssh-keygen -t rsa -b 4096 -C your@email.com 

现在使用ls -al ~/.ssh将显示我们的id_rsa.pub文件。

将SSH密钥添加到SSH代理

eval "$(ssh-agent -s)" # for mac and Linux from bash 
eval `ssh-agent -s` 
 ssh-agent -s # for Windows 

将SHA密钥添加到SHH

ssh-add ~/.ssh/id_rsa 

将密钥复制到剪贴板

clip < ~/.ssh/id_rsa.pub # Windows 
cat ~/.ssh/id_rsa.pub # Linux 

转到GitHub 设置页面然后在生成的密钥中单击“新建SSH密钥”按钮。

然后通过身份验证:

ssh -T git@github.com