Github SSH config containing multiple ssh keys capistrano deployment fails saying Repository not found -


~/.ssh/config

# user_a host github.com-user_a hostname github.com user git preferredauthentications publickey identityfile ~/.ssh/id_rsa identitiesonly yes  # user_b host github.com-user_b hostname github.com user git preferredauthentications publickey identityfile ~/.ssh/id_rsa_user_b identitiesonly yes  # http://serverfault.com/questions/400633/capistrano-deploying-to-different-servers-with-different-authentication-methods host example.com identityfile ~/.ssh_keys/example_env.pem forwardagent yes 

on local machine:

  $ ssh -t git@github.com   hi user_b! you've authenticated, github not provide shell access. 

on remote machine

    ~$ ssh remote_user@example.com      [remote_user@example ~]$ ssh -t git@github.com     hi user_a! you've authenticated, github not provide shell access. 

note:

  • ssh-add -l shows mentioned keys enlisted
  • deploy.rb contains:

     set :repository,  "git@user_b:<repo_name>"   ssh_options[:forward_agent] = true 

i trying deploy application using capistrano amazon ec2 instance .pem file added local machine using ssh-add , can seen enlisted in output ssh-add -l.however facing following error while deploying:

** [example.com :: err] error: repository not found. ** fatal: remote end hung unexpectedly 

following full output of cap deploy command:

$ cap bat deploy    triggering load callbacks * executing `bat'   triggering start callbacks `deploy' * executing `multistage:ensure' * executing `deploy' * executing `deploy:update'    ** transaction: start * executing `deploy:update_code'   updating cached checkout on servers   executing locally: "git ls-remote git@user_b:<repo_name> <branch_name>"   command finished in 6296ms * executing "if [ -d /srv/<app_name>/shared/cached-copy ]; cd /srv/<app_name>/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard df84fadff305e1729991caddde47f6802e424d57 && git clean -q -d -x -f; else git clone -q git@user_b:<repo_name> /srv/<app_name>/shared/cached-copy && cd /srv/<app_name>/shared/cached-copy && git checkout -q -b deploy df84fadff305e1729991caddde47f6802e424d57; fi"   servers: ["example.com"]   [example.com] executing command    ** [example.com :: err] error: repository not found.    ** fatal: remote end hung unexpectedly   command finished in 3811ms   *** [deploy:update_code] rolling * executing "rm -rf /srv/<app_name>/releases/20130723222237; true"   servers: ["example.com"]   [example.com] executing command   command finished in 477ms   failed: "sh -c 'if [ -d /srv/<app_name>/shared/cached-copy ]; cd /srv/<app_name>/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard df84fadff305e1729991caddde47f6802e424d57 && git clean -q -d -x -f; else git clone -q git@user_b:<repo_name> /srv/<app_name>/shared/cached-copy && cd /srv/<app_name>/shared/cached-copy && git checkout -q -b deploy df84fadff305e1729991caddde47f6802e424d57; fi'" on example.com 

so guess error caused due conflicts arising between multiple ssh keys getting detected i.e. on local machine user_b(who member of repository) used default on remote machine user_a(who not having access repository) used.

if assumption correct can please me in getting problem solved? there way in specific user config can used while agent forwarding? if not solution this?

thanks.

ok seems sequence in keys listed in ~/.ssh/config matters.

initially was

    # user_a     host github.com-user_a     hostname github.com     user git     preferredauthentications publickey     identityfile ~/.ssh/id_rsa     identitiesonly yes      # user_b     host github.com-user_b     hostname github.com     user git     preferredauthentications publickey     identityfile ~/.ssh/id_rsa_user_b     identitiesonly yes      # http://serverfault.com/questions/400633/capistrano-deploying-to-different-servers-with-different-authentication-methods     host example.com     identityfile ~/.ssh_keys/example_env.pem     forwardagent yes 

afterwards did this:

    # user_b     host github.com-user_b     hostname github.com     user git     preferredauthentications publickey     identityfile ~/.ssh/id_rsa_user_b     identitiesonly yes      # user_a     host github.com-user_a     hostname github.com     user git     preferredauthentications publickey     identityfile ~/.ssh/id_rsa     identitiesonly yes       # http://serverfault.com/questions/400633/capistrano-deploying-to-different-servers-with-different-authentication-methods     host example.com     identityfile ~/.ssh_keys/example_env.pem     forwardagent yes 

but after doing didn't restarted machine, changes not in effect.

this morning after started machine after posting above problem found working:

on local machine:

  $ ssh -t git@github.com   hi user_b! you've authenticated, github not provide shell access. 

on remote machine

  $ ssh -t git@github.com   hi user_b! you've authenticated, github not provide shell access. 

hope helps else in case faces similar problem.

thanks.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -