Git 无法通过 ssh Deployer 克隆项目

时间:2021-02-04 15:33:15

标签: php git ssh php-deployer

我正在使用 Deployer 将项目克隆到服务器上,但尽管设置了部署密钥,但由于某种原因,通过 SSH 克隆失败:

ERROR: Repository not found.
fatal: Could not read from remote repository.

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

我采取的步骤:

  1. 在我克隆项目的服务器上生成新密钥:ssh-keygen -t rsa -b 4096 -C "your_email@example.com",我的密钥文件采用以下格式:form_simple_id_rsa,当然还有 pub 版本。
  2. 做了 eval 并添加了密钥:ssh-add -k ~/.ssh/form_simple_id_rsa
  3. 已测试连接,一切正常。
  4. form_simple_id_rsa.pub 密钥作为部署密钥添加到我的存储库中,存储库所有者不是我的帐户,我是此存储库的协作者,但服务器的密钥已链接到项目,因此应该是能够克隆。
  5. 在我的项目中设置部署器以使用我的主机、端口和我制作的新密钥(因为有几个密钥)等:
host('project')
    ->port(myport)
    ->identityFile('~/.ssh/form_simple_id_rsa')
    ->stage('production')
    ->set('repository', 'git@github.com:company/project.git')
    ->user('root')
    ->set('deploy_path', '/var/www/path');
  1. 尝试部署,得到一个错误退出代码:
Exit Code: 128(Invalid exit argument)

ssh -A -tt 命令失败。

1 个答案:

答案 0 :(得分:0)

如果这不是 Deployer 版本问题 (as in here),我会尝试:

  • 生成和测试没有密码的密钥(为了避免 ssh-add step,确保不需要密码)
  • 使用 -m PEM 生成一个密钥,以使用旧的 PEM 格式而不是新的 OPENSSH 格式,以防它有任何影响