18

I've followed several suggestions from other sites but to no avail. When I try cap deploy:cold I consistently get "Host key verification failed."

I've tried everything. I've ssh'd from my computer to the remote, removed and readded both keys from known-hosts, cloned from github, set up my public key from both the server and local on github.

What am I missing here?


Capfile: https://gist.github.com/1308243


Errors: https://gist.github.com/1308255

5
  • did you add ssh_options[:forward_agent] = true to deploy.rb? Oct 22, 2011 at 22:58
  • i can only point you to this article from github then and see if you can solve it: help.github.com/deploy-with-capistrano Oct 22, 2011 at 23:18
  • Can you attach your Capfile and the log from your terminal output? Oct 23, 2011 at 4:14
  • 2
    Also, I've read that cap deploy:cold is somewhat deprecated. I use cap deploy:setup to verify that the server is properly set up, then cap deploy to test it out. Oct 23, 2011 at 4:15
  • Attached output and tried deploy:setup. It worked, but when I do just a straight cap:deploy I get: gist.github.com/1308273
    – danhere
    Oct 24, 2011 at 3:02

5 Answers 5

81

Add to your deploy.rb:

ssh_options[:forward_agent] = true
default_run_options[:pty] = true

Or log in to the server(s) you are deploying to (as your deploy user) and run:

ssh [email protected]
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is **:**:**:.
Are you sure you want to continue connecting (yes/no)? yes

Most of the time I see this issue is when github.com in not in your ~/.ssh/known_hosts

3
  • 3
    +1 to adding github to the known host list. this is often the root cause of this problem.
    – Greg
    Mar 5, 2012 at 18:30
  • 1
    The same as greg. I added the public key of the server to github but I didn't try connecting to it. $ ssh [email protected] was fine.
    – Bachet
    Mar 16, 2012 at 19:32
  • It worked. But along with this, I need to generate a key on my server(which is a new one) and add that in github account & its working!
    – Prem
    Jun 14, 2013 at 13:23
6

Instead of using a git ssh url which looks like this [email protected]:definelabs/urbanairship.git

use a read only url which looks like this git://github.com/definelabs/urbanairship.git

1
  • doesn't seem to apply any more because there are no read only repo URLs for private repositories
    – alex
    May 9, 2013 at 1:45
1

You had mentioned that cap deploy:setup worked and cap deploy failed. So looks like the error message is not related to the ssh connectivity, and its related to git checkout. It might be because that your git remote server works with key based authentication and the required key is missing in the server.

0

In addition to

ssh_options[:forward_agent] = true
default_run_options[:pty] = true

I also needed do this, with below:

def add_domain_to_known_hosts(hostname)
  ip_address = "`dig +short A #{hostname}`"
  run "ssh-keygen -R #{hostname}"
  run "ssh-keygen -R #{ip_address}"
  run "ssh-keygen -R #{hostname},#{ip_address}"
  run "ssh-keyscan -H #{hostname},#{ip_address} >> ~/.ssh/known_hosts"
  run "ssh-keyscan -H #{ip_address} >> ~/.ssh/known_hosts"
  run "ssh-keyscan -H #{hostname} >> ~/.ssh/known_hosts"
end

Although, it should be noted that PTY's are discouraged by capistrano: https://github.com/capistrano/capistrano#a-word-about-ptys

-1

One file to get concerned with ~/YOUR_USER_NAME /.ssh/authorized_keys2 on the server. I believe it should contain the public/private key (one of the two, I think private?)

1
  • 7
    The authorized_keys file on the server should have the text of your public key, which is often file .ssh/id_rsa.pub on your local machine. Oct 23, 2011 at 15:11

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.