New to Git or GitHub? For a deeper understanding check out GitHub’s explanation.
Git或GitHub的新手? 要获得更深入的了解,请查看GitHub的说明 。
什么是SSH? (What is SSH?)
SSH (Secure Shell) protocol is a software package that enables secure system administration and file transfers over insecure networks. SSH protocols use encryption to secure the connection between client and server. All user authentication, commands, output, and file transfers are encrypted to protect against attacks.
SSH(安全外壳)协议是一个软件包,可以通过不安全的网络进行安全的系统管理和文件传输。 SSH协议使用加密来保护客户端和服务器之间的连接。 所有用户身份验证,命令,输出和文件传输都经过加密,以防止受到攻击。
为什么要使用SSH密钥? (Why use an SSH key?)
When working with a GitHub repository, you’ll often need to identify yourself to GitHub using your username and password. An SSH key is an alternate way to identify yourself that doesn’t require you to provide your credentials every time.
使用GitHub存储库时,通常需要使用用户名和密码在GitHub上标识自己。 SSH密钥是另一种标识自己的身份,不需要您每次都提供凭据。
SSH keys come in pairs, a public key that gets shared with services like GitHub, and a private key that is stored only on your computer. If the keys match, you’re granted access.
SSH密钥成对出现,与GitHub等服务共享的公用密钥和仅存储在您的计算机上的专用密钥 。 如果密钥匹配,则将授予您访问权限。
Note: you should never share your private key
注意:永远不要共享您的私钥
The encryption behind SSH keys ensures that no one can derive your private key from the public one.
SSH密钥背后的加密确保了没有人可以从公共密钥中派生您的私有密钥。
逐步SSH设置说明 (Step by step SSH setup instructions)
Create a GitHub account.
创建一个GitHub帐户。
Download and install git.
下载并安装git 。
- Set up git with your user name and email, Open a terminal/shell and type: 使用您的用户名和电子邮件设置git,打开终端/外壳并键入:
$ git config --global user.name "Your name here"
$ git config --global user.email "your_email@example.com"
- Set up SSH on your computer for password-less logins. The first step in using SSH authorization with GitHub is to generate your SSH key pair. 在计算机上设置SSH以进行无密码登录。 在GitHub中使用SSH授权的第一步是生成SSH密钥对。
You might already have an SSH key pair on your machine. Look to see if you have any files under
~/.ssh/id_rsa
and~/.ssh/id_rsa.pub
. If you see, you already have a key pair and don't need to create a new one.您的计算机上可能已经有一个SSH密钥对。 查看是否在
~/.ssh/id_rsa
和~/.ssh/id_rsa.pub
下有任何文件。 如果看到的话,您已经有了一个密钥对,不需要创建一个新的密钥对。Generate SSH key using
$ ssh-keygen -t rsa -C "your_email@example.com"
使用
$ ssh-keygen -t rsa -C "your_email@example.com"
生成SSH密钥
When asked where to save the new key, hit enter to accept the default location.
当系统询问您将新密钥保存在何处时,请按Enter键以接受默认位置。
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_rsa):
Next, add your public key to your Github profile. Now you should be able to push to Github without entering your username or password.
接下来,将您的公钥添加到您的Github个人资料中 。 现在,您无需输入用户名或密码就可以推送到Github。
翻译自: https://medium.com/frontend-digest/github-password-less-authentication-ssh-3b4f90fb8de3