2014-12-08 65 views
3

我無法使用我的部署密鑰將我的存儲庫克隆到遠程EC2 ubuntu實例。 以下是我遵循的步驟。使用部署密鑰(bitbucket)無法克隆EC2

  1. 我刪除了現有部署鑰匙我在我的帳戶到位桶
  2. 我打掃~/.ssh/know_hosts以下https://stackoverflow.com/a/26520681/808734
  3. 我產生我的新的密鑰以下these steps 並將其添加爲一個deployment key來回購。
  4. 這裏是ssh -T [email protected]

    You can use git or hg to connect to Bitbucket. Shell access is disabled. This deploy key has read access to the following repositories: username/repository: KEYNAME -- [email protected]

  5. 輸出但是當我嘗試克隆庫
    sudo git clone [email protected]:username/repository.git我收到以下錯誤 Cloning into 'repository'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

我在這裏失去了一些東西?任何人有任何建議?

感謝您的閱讀。

回答

9

那麼這是尷尬,這裏的問題是我運行的命令爲sudo用戶。

sudo git clone [email protected]:username/repository.git 

這可能是試圖以root用戶身份克隆存儲庫並導致錯誤。但是,作爲當前用戶進行克隆,並向所需目錄提供寫入權限,讓我可以成功克隆存儲庫。

另外在此過程中,我的ssh密鑰似乎已被重置,因此請確保ssh -T [email protected]按預期工作。如果沒有,運行

# start the ssh-agent in the background 
eval "$(ssh-agent -s)" 
# Agent pid 59566 
ssh-add ~/.ssh/id_rsa 

爲我工作。 more details

+1

'ssh-add'救了我。即使在我創建了一個新的密鑰並嘗試了這個密鑰之後,我不得不用ssh-add手動添加它。做得好! – Aarmora 2016-05-27 17:27:07

+0

哇!做到了!如果不是問題,請告訴我真正的問題是什麼,這段代碼做了什麼? – BlackBurn027 2017-09-14 14:25:52

1
fatal: Could not read from remote repository. 
Please make sure you have the correct access rights and the repository exists. 

似乎是很多GIT用戶的一個重複發生的問題。

請務必使用正確的用戶名和網址!

git: fatal: Could not read from remote repository會有幫助。

Goodluck!

0

如果你是團隊的一部分,並試圖克隆版本庫,那麼你可能需要一點即

更改網址

SSH://[email protected] TEAM_NAME/repo_name.git

SSH://[email protected] / TEAM_NAME/repo_name。git