生成並部署SSH key

在win7安裝完Git,使用Git Bash輸入命令步驟以下:git

一、git config --global user.name "usernme"github

二、git config --global user.email emailNameruby

三、git bash 進入工程目錄:git initbash

四、使用git add filename 將文件添加到庫服務器

五、使用git commit -m "first commit" 進行提交ssh

六、使用ssh-keygen -C 'emailName@163.com' -t rsaspa

七、在pub文件中copy key,添加當GitHub中的SSH keys3d

八、ssh -T git@github.com進行驗證出現錯誤:Permission denied (publickey).code

這該怎麼解決?查找了不少資料,都沒有解決!(emailName@163.com是我GitHub註冊郵箱,username是我GitHub的用戶名)圖片

 

官方:

1.如何生成ssh公鑰

你能夠按以下命令來生成 sshkey:

ssh-keygen -t rsa -C "xxxxx@xxxxx.com" # Generating public/private rsa key pair... # 三次回車便可生成 ssh key 

查看你的 public key,並把他添加到碼雲(Gitee.com) SSH key添加地址:https://gitee.com/profile/sshkeys)

cat ~/.ssh/id_rsa.pub # ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc.... 

添加後,在終端(Terminal)中輸入

ssh -T git@gitee.com 

若返回

Welcome to Gitee.com, yourname! 

則證實添加成功。


2.怎麼添加用戶 ssh key?

  1. 進入我的設置頁面---》SSH 公鑰添加,具體連接
  2. 截圖以下 輸入圖片說明

3.項目的 ssh key 和用戶的 ssh key 兩處地方有什麼不一樣?

項目的 sshkey 只針對項目,且咱們僅對項目提供了部署公鑰,即項目下的公鑰僅能拉取項目,這一般用於生產服務器拉取倉庫的代碼。 而用戶的 key 則是針對用戶的,用戶添加了 key 就對用戶名下的項目和用戶參加了的項目具備權限,通常而言,用戶的key具備推送和拉取的權限,而項目的 key 則只具備拉取權限。

 

在win7安裝完Git,使用Git Bash輸入命令步驟以下:

一、git config --global user.name "usernme"

二、git config --global user.email emailName

三、git bash 進入工程目錄:git init

四、使用git add filename 將文件添加到庫

五、使用git commit -m "first commit" 進行提交

六、使用ssh-keygen -C 'emailName@163.com' -t rsa

七、在pub文件中copy key,添加當GitHub中的SSH keys

八、ssh -T git@github.com進行驗證出現錯誤:Permission denied (publickey).

這該怎麼解決?查找了不少資料,都沒有解決!(emailName@163.com是我GitHub註冊郵箱,username是我GitHub的用戶名)

相關文章
相關標籤/搜索