免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
如何向git賬號上提交代碼

官方說明:https://help.github.com/articles/generating-ssh-keys/

1,為Github賬戶設置SSH key

文章地址:http://zuyunfei.com/2013/04/10/setup-github-ssh-key/

什么是SSH key

一直使用SSH連接服務器,但是對它的原理卻不太了解。這次設置Octopress的時候,需要使用SSH 方式連接Github, 正好對SSH的工作方式做了下了解。(好像Github推薦使用HTTPS的方式訪問repo, 以前Github受到過SSH密匙攻擊,之后升級了SSH key的安全措施,https方式視乎更方便安全,不過Octopress的設置文檔中,我并沒有找到怎么使用HTTPS連接Github)

簡單來說,SSH提供了兩種級別的安全驗證:

  1. 第一種級別是基于密碼的安全驗證,知道賬號和密碼,就可以登陸到遠程主機。Team的開發(fā)工作中,就是使用這種方式登陸編譯服務器,或者開發(fā)機器。因為是在內(nèi)網(wǎng)中,這種級別的安全驗證已經(jīng)足夠了。
  2. 第二種級別是基于Public-key cryptography (公開密匙加密)機制的安全驗證,原理如下圖所示:

其優(yōu)點在于無需共享的通用密鑰,解密的私鑰不發(fā)往任何用戶。即使公鑰在網(wǎng)上被截獲,如果沒有與其匹配的私鑰,也無法解密,所截獲的公鑰是沒有任何用處的。

產(chǎn)生SSH key

根據(jù)Github提供的help文檔,具體過程如下

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


使用ssh-keygen產(chǎn)生新的key

1234
$ 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):


使用默認的文件名直接enter, 按提示輸入密碼(如果不提供密碼,SSH將無密碼連接,如果private key泄露可能會有安全問題)

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


密匙產(chǎn)生成功

1234
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

上傳public key到Github賬戶

  1. 登錄github
  2. 點擊右上方的Accounting settings圖標
  3. 選擇 SSH key
  4. 點擊 Add SSH key

在出現(xiàn)的界面中填寫SSH key的名稱,填一個你自己喜歡的名稱即可,然后將上面拷貝的~/.ssh/id_rsa.pub文件內(nèi)容粘帖到key一欄,在點擊“add key”按鈕就可以了。
添加過程github會提示你輸入一次你的github密碼

設置SSH使用HTTPS的403端口

在局域網(wǎng)中SSH的22端口可能會被防火墻屏蔽,可以設置SSH使用HTTPS的403端口。

測試HTTPS端口是否可用

123
$ ssh -T -p 443 git@ssh.github.comHi username! You've successfully authenticated, but GitHub does notprovide shell access.


編輯SSH配置文件 ~/.ssh/config 如下:

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


測試是否配置成功

123
$ ssh -T git@github.comHi username! You've successfully authenticated, but GitHub does notprovide shell access.

多個Github賬號的SSH key切換

如果在一臺機器上要登陸多個Github賬戶,需要一些配置,雖然現(xiàn)在并沒有用到,但是先記下來以備不時之需,過程參看這里。

 

2,【GitHub】解決每次push代碼到github都需要輸入用戶名和密碼的方法

在github上,建立一個項目test,去主頁查看可以看到

 

如果使用HTTPS:

 

Create a new repository on the command line

touch README.mdgit initgit add README.mdgit commit -m "first commit"git remote add origin https://github.com/guochy2012/test.gitgit push -u origin master

Push an existing repository from the command line

git remote add origin https://github.com/guochy2012/test.gitgit push -u origin master

 

 

如果采用SSH:

 

Create a new repository on the command line

touch README.mdgit initgit add README.mdgit commit -m "first commit"git remote add origin git@github.com:guochy2012/test.gitgit push -u origin master

Push an existing repository from the command line

git remote add origin git@github.com:guochy2012/test.gitgit push -u origin master

 

 

使用HTTPS需要每次輸入密碼,SSH則不用,但SSH需要配置密鑰 。

關于怎么產(chǎn)生密鑰可以參見《Generating SSH Keys》一文

 

3,github地址 從https改成ssh

打開命令行工具,運行 git remote set-url origin 例如:

1
2
3
4
$ git remote set-url origin git@github.com:user/repo.git

然后再次 commit,如果出現(xiàn)類似:

1
2
3
4
Permission denied (publickey).

字樣,那么說明你的 SSH key 沒有設置或已經(jīng)失效(譬如升級到 Mountain Lion 系統(tǒng)后),請重新參照上文的官方文檔進行設置即可。

4,執(zhí)行pull時報錯

wangkongming@AY140527171808170503Z:~/github/collect$ git pull
Warning: Permanently added the RSA host key for IP address '192.30.252.130' to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/wangkongming/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /home/wangkongming/.ssh/id_rsa
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

答案:http://stackoverflow.com/questions/1556119/ssh-private-key-permissions-using-git-gui-or-ssh-keygen-are-too-open

是因為給 id_rsa的權(quán)限太高了,改成700就可以了。也有人說600

You changed the permissions on the whole directory, which I agree with Splash is a bad idea. If you can remember what the original permissions for the directory are, I would try to set them back to that and then do the following

cd ~/.sshchmod 700 id_rsa

inside the .ssh folder. That will set the id_rsa file to rwx (read, write, execute) for the owner (you) only, and zero access for everyone else.

If you can't remember what the original settings are, add a new user and create a set of SSH keys for that user, thus creating a new .ssh folder which will have default permissions. You can use that new .ssh folder as the reference for permissions to reset your .ssh folder and files to.

If that doesn't work, I would try doing an uninstall of msysgit, deleting ALL .ssh folders on the computer (just for safe measure), then reinstalling msysgit with your desired settings and try starting over completely (though I think you told me you tried this already).

Edited: Also just found this link via Google --  While it's targeted at linux, it might help since we're talking liunx permissions and such.

 

======================================

以下是自己在使用git時,總結(jié)的:

1,查看當前項目遠程分支的路徑

git remote -v

 

打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
windows上 使用msysgit的步驟及遇到的若干問題
mac下git與github簡單使用
git/github學習筆記
在VSCode中使用碼云(Gitee)進行代碼管理
git push 每次都需要輸入用戶名和密碼
Hexo系列(一) 搭建博客網(wǎng)站
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服