Home>

I have a question about deploy settings in Rails and Capistrano.
I have a question about the connection between AWS EC2 and GitHub.
If i type the following command locally, the following error will appear.

bundle exec cap production deploy: check

00:01 git: check
      01 git ls-remote [email protected]: User name/Repository name.git HEAD
      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 ec2 username @ IP address: 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.

Caused by:
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.

You can connect to EC2 locally.
On EC2, GitHub can be connected to SSH and git clone and git pull are possible.

When you git clone or git pull with EC2, you will be asked for the key passphrase, but with Capistrano you will not be able to ask for the key passphrase. I don't know ...

Thanks for your advice.

  • Answer # 1

    It was solved by executing the following on the EC2 server and local application directory.

    ssh-add ~/.ssh/key file name

Related articles