28489


Staging環境にデプロイしたいのですが、下記のエラーが出て動きません。

[code]

      [git][* hoge-hoge-hoge]:~/projects/hoge/ bundle exec cap stage deploy
      00:00 git:wrapper
            01 mkdir -p /tmp/hoge/
          ✔ 01 deployer@hoge.poge.me 0.226s
            Uploading /tmp/hoge/git-ssh.sh 100.0%
            02 chmod +rx /tmp/hoge/git-ssh.sh
          ✔ 02 deployer@hoge.poge.me 0.025s
      00:00 git:check
            01 git ls-remote --heads git@github.com:poge/hoge.git
            01 Permission denied (publickey).
            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@hoge.poge.me: git exit status: 128
      git stdout: Nothing written
      git stderr: Permission denied (publickey).
      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: Permission denied (publickey).
      fatal: Could not read from remote repository.
    
      Please make sure you have the correct access rights
      and the repository exists.
    
      Tasks: TOP => git:check
      (See full trace by running task with --trace)
      The deploy has failed with an error: Exception while executing as deployer@hoge.poge.me: git exit status: 128
      git stdout: Nothing written
      git stderr: Permission denied (publickey).
      fatal: Could not read from remote repository.
    
      Please make sure you have the correct access rights
      and the repository exists.
    
      ** DEPLOY FAILED
      ** Refer to log/capistrano.log for details. Here are the last 20 lines:
    
      Please make sure you have the correct access rights
      and the repository exists.
        INFO ---------------------------------------------------------------------------
        INFO START 2016-08-24 19:39:34 +0900 cap stage deploy
        INFO ---------------------------------------------------------------------------
        INFO [90de94b6] Running /usr/bin/env mkdir -p /tmp/hoge/ as deployer@hoge.poge.me
       DEBUG [90de94b6] Command: /usr/bin/env mkdir -p /tmp/hoge/
        INFO [90de94b6] Finished in 0.226 seconds with exit status 0 (successful).
       DEBUG Uploading /tmp/hoge/git-ssh.sh 0.0%
        INFO Uploading /tmp/hoge/git-ssh.sh 100.0%
        INFO [6247b79d] Running /usr/bin/env chmod +rx /tmp/hoge/git-ssh.sh as deployer@hoge.poge.me
       DEBUG [6247b79d] Command: /usr/bin/env chmod +rx /tmp/hoge/git-ssh.sh
        INFO [6247b79d] Finished in 0.025 seconds with exit status 0 (successful).
        INFO [a7f4afba] Running /usr/bin/env git ls-remote --heads git@github.com:poge/hoge.git as deployer@hoge.poge.me
       DEBUG [a7f4afba] Command: ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/hoge/git-ssh.sh" ; /usr/bin/env git ls-remote --heads git@github.com:poge/hoge.git )
       DEBUG [a7f4afba]     Permission denied (publickey).
       DEBUG [a7f4afba]     fatal: Could not read from remote repository.
    
      Please make sure you have the correct access rights
      and the repository exists.
    
[/code]

git ls-remoteで失敗している（`Permission denied (publickey).`）ようなのですが解決方法を教えてください。


CC BY-SA 3.0
2016-08-25T01:14:11.260
28477
2016-08-25T23:12:39.433
2016-08-25T01:43:15.600
5519
10851
question
ruby-on-rails capistrano
cap stage deployを実行するとPermission denied (publickey)というエラーが起こる


秘密鍵をssh-addすることで解決しました。

[code]

    ssh-add ~/.ssh/id_rsa
    
[/code]


CC BY-SA 3.0
2016-08-25T12:51:08.587
28489
2016-08-25T23:12:39.433
2016-08-25T23:12:39.433
10851
10851
28477
answer