I try to deploy a private repository using mina.
I have generated a public SSH key on my server which I then added to my GitHub user. Being logged into my server, I can do a git clone git@github.com:Access4all/a4aa2.git
. But from my local machine, when executing mina deploy
, I get the following error:
-----> Loading environment
-----> Creating a temporary build path
-----> Fetching new git commits
Warning: Permanently added the RSA host key for IP address '192.30.252.130' to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
! ERROR: Deploy failed.
-----> Cleaning up build
What looks strange to me is the fact that the IP 192.30.252.130
is added to the list of known hosts, although I already did this before when manually ssh'ing. And the IP of my server is 192.30.252.130
(bellatrix.uberspace.de)!
My deploy.rb
config section looks like this:
set :server_name, 'bellatrix'
set :user, 'a4aa2'
set :repository_name, 'a4aa2'
set :domain, "#{server_name}.uberspace.de"
set :deploy_to, "/home/#{user}/rails"
set :repository, "git@github.com:Access4all/#{repository_name}.git"
set :branch, 'master'
Did I conceptually understand something wrong?
Update
I just noticed that the passphrase is aked when doing a manual git clone:
[a4aa2@bellatrix tmp]$ git clone "git@github.com:Access4all/a4aa2.git"
Initialized empty Git repository in /home/a4aa2/tmp/a4aa2/.git/
Enter passphrase for key '/home/a4aa2/.ssh/id_rsa':
I guess that Mina fails because of this. Is this normal? Why do I have to enter the passphrase? How can I circumvent it?
Update
According to Step 3: Add your key to the ssh-agent, I can save the passphrase to ssh-agent.
But it seems that I'm somehow not able to save it the way it's described there.
I can add it like this:
[a4aa2@bellatrix tmp]$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /home/a4aa2/.ssh/id_rsa:
Identity added: /home/a4aa2/.ssh/id_rsa (/home/a4aa2/.ssh/id_rsa)
And then I can successfully clone the repository without entering the passphrase. But after logout and login again, I have to enter it again. Somehow the ssh-agent doesn't seem to work between session?
I just found out that I don't need a private/public key pair on my hoster, because I can simply activate the forward_agent
option of mina:
set :forward_agent, true