Git hub publickey 配置

git config –global user.name “dracuka” //配置用户名

git config –global user.email “[email protected]” //配置email

生成ssh key

使用命令 ssh-keygen -t rsa -C “[email protected]//your_email是你的email,比如[email protected]
如果有提示一路enter下去,不用输入啥信息。或者你也可以设置一个口令,每次clone或者push的时候需要输入。
假如你用的root用户,上面命令执行成功后会在目录/root/.ssh/下面生成文件id_rsa.pub

wangdongwen@greenvm-w10921v:~$ sudo ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
85:89:7f:fa:cf:9c:f6:f9:3c:d9:ec:d9:7f:ba:e6:a4 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|       . o       |
|      . o .      |
|       . .       |
|        S .      |
|         o       |
|        .     ..o|
|         . o.+.=*|
|          .oE+**X|
+-----------------+

 

github上添加ssh key

在个人设置页面(personal settings),点击SSH and GPG Keys,添加一个ssh key,title名字随便填,key文本框里就复制步骤3中id_rsa.pub里面的所有内容(记得是所有内容,包括那个邮件名)。
 

验证ssh key是否设置成功

执行命令ssh -T [email protected]
如果提示access dennied就是没设置成功
提示You’ve successfully authenticated, but GitHub does not provide shell access

 

 

Github create repo

git init
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:dracuka/job.git //这里的dracuka更换成自己的github用户名 
git push -u origin master

…or push an existing repository from the command line

git remote add origin [email protected]:dracuka/job.git
git push -u origin master

 

你可能感兴趣的:(零碎知识)