簡體   English   中英

Capistrano 3部署:致命:無法從遠程存儲庫讀取

[英]Capistrano 3 deploy: fatal: Could not read from remote repository

我有一個Rails 5和Capistrano 3應用程序。

我能夠將代碼推送到git存儲庫,也可以從那里拉過來。

但是,當我嘗試通過Capistrano將代碼部署到(DigitalOcean)服務器時,出現以下錯誤消息:

00:02 git:check
      01 git ls-remote git@bitbucket.org:username/reponame.git HEAD
      01 repository access denied.
      01 fatal: Could not read from remote repository.
      01
      01 Please make sure you have the correct access rights
      01 and the repository exists.
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deployer@IP: git exit status: 128
git stdout: Nothing written
git stderr: repository access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

SSHKit::Command::Failed: git exit status: 128
git stdout: Nothing written
git stderr: repository access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Tasks: TOP => deploy:check => git:check
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deployer@IP: git exit status: 128
git stdout: Nothing written
git stderr: repository access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


** DEPLOY FAILED

我做了什么:我在Mac上生成了一個新的SSH密鑰,輸出位於名為project_nameproject_name.pub的文件中。 然后我運行了以下命令:

cat ~/.ssh/project_name.pub | pbcopy

並將此密鑰代碼粘貼到Bitbucket存儲庫的“設置”部分中。

在Capistrano配置文件中,我具有以下內容:

set :ssh_options, {
  keys: %w(/Users/my_name/.ssh/project_name),
  forward_agent: true,
  auth_methods: %w(publickey password),
  port: 22
}

當我運行cap production deploy ,系統會要求我輸入密碼,然后,由於上述錯誤,部署過程將失敗( Please make sure you have the correct access rights and the repository exists. )。

如何正確設置密鑰/解決部署問題?

看來您的SSH密鑰沒有被轉發。 通常是因為您的SSH密鑰不可用於ssh-agent進行轉發。 Github對此有很好的記錄 ,但是您可能只需要運行: ssh-add project_name

您可能還需要更改Github文章介紹的SSH配置,但我僅從ssh-add

請注意,我基於您的forward agent: true假設是,您正在嘗試通過將本地SSH密鑰轉發到Github進行部署,而不使用應用程序服務器上存在的部署密鑰。 如果不是這種情況,並且您的部署密鑰在服務器上,則將其設置為false。

希望您在存儲庫中正確添加ssh密鑰。我認為您正在使用git clone https://user@bitbucket.org/appname.git類的HTTPS克隆存儲庫,因為bitbucket是私有存儲庫,請用git clone https://user@bitbucket.org/appname.git ssh替換git clone https://user@bitbucket.org/appname.git ,請記住不要在小滴中創建ssh密鑰時添加密碼,請將其保留為空白。希望此幫助對將來的Rails愛好者有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM