为Github账户设置SSH key

来源:互联网 发布:网络淦是什么意思 编辑:程序博客网 时间:2024/06/05 10:26

原理

1.产生SSH key

1.0先检查是否已经生成过了

$ cd ~/.ssh# Checks to see if there is a directory named ".ssh" in your user directory

1.1使用ssh-keygen产生新的key

$ ssh-keygen -t rsa -C "your_email@example.com"# Creates a new ssh key using the provided emailGenerating public/private rsa key pair.Enter file in which to save the key (/home/you/.ssh/id_rsa):

1.2使用默认的文件名直接enter, 按提示输入密码(如果不提供密码,SSH将无密码连接,如果private key泄露可能会有安全问题)

Enter passphrase (empty for no passphrase): [Type a passphrase]Enter same passphrase again: [Type passphrase again]

1.3密匙产生成功

Your identification has been saved in /home/you/.ssh/id_rsa.Your public key has been saved in /home/you/.ssh/id_rsa.pub.The key fingerprint is:01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

2.上传public key到Github账户

2.1登录github

2.2点击右上方的Accounting settings图标

2.3选择 SSH key

2.4点击 Add SSH key

0 0
原创粉丝点击