エラーの内容
deployerでデプロイしようとすると「Failed to execute git clone」のエラーが出る
[root@localhost deployer_test]# php deployer.phar deploy
✈︎ Deploying 1.7/master on localhost
✔ Executing task deploy:prepare
✔ Executing task deploy:lock
✔ Executing task deploy:release
✔ Executing task deploy:update_code
✔ Executing task deploy:shared
➤ Executing task deploy:vendors
To speed up composer installation setup "unzip" command with PHP zip extension https://goo.gl/sxzFcD
✔ Executing task deploy:failed
In Client.php line 96:
The command "cd /home/vagrant/work/releases/1 && /usr/bin/php /usr/local/bin/composer install --verbose --prefer-dist --no-progress --no-interacti
on --no-dev --optimize-autoloader" failed.
Exit Code: 1 (General error)
Host Name: dev
================
Loading composer repositories with package information
Failed to clone the git@github.com:fuel/docs.git repository, try running in interactive mode so that you can enter your GitHub credentials
[RuntimeException]
Failed to execute git clone --mirror 'git@github.com:fuel/docs.git' '/home/vagrant/.cache/composer/vcs/git-github.com-fuel-docs.git/'
問題のコマンドを手で叩いても確かにエラーになる
git clone --mirror 'git@github.com:fuel/docs.git' '/home/vagrant/.cache/composer/vcs/git-github.com-fuel-docs.git/'
Cloning into bare repository '/home/vagrant/.cache/composer/vcs/git-github.com-fuel-docs.git'
...
Permission denied (publickey).
fatal: Could not read from remote repository.
試しに、リポジトリ名を"http://github..."の形に変更するとcloneできる
# git clone http://github.com/fuel/docs.git
Cloning into 'docs'...
remote: Counting objects: 12898, done.
remote: Total 12898 (delta 0), reused 0 (delta 0), pack-reused 12898
Receiving objects: 100% (12898/12898), 4.46 MiB | 309.00 KiB/s, done.
Resolving deltas: 100% (7651/7651), done.
行った事
認証の問題っぽいので、試しに自分のgithubアカウントへsshキーファイルを登録してみた。
手元のmacでsshのキーファイルを作る
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/akamist/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/akamist/.ssh/id_rsa.
Your public key has been saved in /Users/akamist/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:xxxxx....
キーファイルが.sshにできたことを確認
$ ls -l ~/.ssh
total 24
-rw------- 1 aka staff 1675 4 13 09:05 id_rsa
-rw-r--r-- 1 aka staff 389 4 13 09:05 id_rsa.pub
-rw-r--r-- 1 aka staff 427 4 8 16:49 known_hosts
id_rsa.pubをgithubに登録 (https://github.com/setting/keys)
deployerを動かしているサーバにid_rsaをコピー
再度、下記のコマンドを手で実行したらOKになった
git clone --mirror 'git@github.com:fuel/docs.git' '/home/vagrant/.cache/composer/vcs/git-github.com-fuel-docs.git/'
emote: Counting objects: 14496, done.
remote: Total 14496 (delta 0), reused 0 (delta 0), pack-reused 14496
Receiving objects: 100% (14496/14496), 4.87 MiB | 510.00 KiB/s, done.
Resolving deltas: 100% (8310/8310), done.
こちらもおススメ