Intercity chef-repo Capistrano asking for deploy password - ruby-on-rails

I have set up a vps everything according to the https://github.com/intercity/chef-repo instructions. I have set up Capistrano but when i try cap production deploy:check
it keeps asking for deploy password. But i don't have one because it is generated through the intercity node. I have the public key of my server in the node file.

Check that you can log in via normal SSH manually. Guessing you didn't get the SSH keys installed correctly.

Related

Changing remote of git does not work on digital ocean

I'm deploying a rails app on digital ocean, following this link. When I followed the exact steps, it worked perfectly. But then I realized the github repository is public. I should have it as private. I create a private repository and changed the remote origin in my local. I put the ssh keys in the new private repository. Removed the old apps folder in the server. And then tried to clone from the remote repository but it asks for password. (It should have taken the ssh key??).
Also I changed the deploy.rb and nginx.conf to reflect the changes of the remote repository and then gave this command, cap production deploy:initial, but it fails, due to authentication failure in git.
Why does it fail? Why is the ssh key not taking effect?
Maybe it is because you have not enabled ssh forwarding for digital ocean? To verify, first edit the $HOME/.ssh/config on your local pc:
host *
ForwardAgent yes
Now try to run cap production deploy:initial. If it works without a password now, then you should change the host * to actually match the hostname of your ssh host, so ForwardAgent is only set for digital ocean:
host digitalocean.com
ForwardAgent yes
For your use case: ForwardAgent enables the server to use your local ssh keys, so your deploy user has the same "ssh rights" like your local user.
This looks like capistrano is still using the old git remote address. When you change the remote url, it is not enough to do this inside deploy.rb etc, but you have to manually change the file repo/config inside the deployment dir of capistrono on the server when you already deployed it with an old remote url before.
So, if you have the following inside your deploy.rb (or deploy/production.rb)
set :deploy_to, '/var/www/path/to/deploy'
You have to manually edit the file on the server
/var/www/path/to/deploy/repo/config
and amend the url = XXX entry of your remote to match the new one.

Can a Rails app be deployed without using Heroku Toolbelt? If so, how?

I want to deploy rails app without using Heroku ToolBelt. Is it possible? If so, how? I'm only allowed to use Heroku dashboard; I'm not allowed to use any other cloud service :(
I have to run PostgreSQL commands, adding add-ons and setting configuration variables and possibly other tasks for which we have Heroku Toolbelt to deploy a application in production environment.
Error:
user#xx ~/Desktop/github/blog (master)
$ git push git#heroku.com:herokugui.git master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I don't want to use Heroku Toolbelt. That's why I am using Git commands to deploy code on Heroku. I am not able to push code to Heroku using Git commands. Is it possible to do this task without the toolbelt?
Another question I have is: is there any way to run PostgreSQL commands on Heroku GUI? If so, how?
It's not easy (as with Heroku toolbelt), but it's possible. It involves hanging around your Heroku dashboard at least, so make sure you can access it.
First off, you need a key. If you're on a Linux machine (as me), then in your home directory you should have a folder named .ssh (it may be hidden, hit Ctrl+H to reveal, again, if Linux) and a file id_rsa.pub in there. If not, you need to generate your SSH key first.
ssh-keygen -t rsa
That will prompt you for a folder, default is fine, just hit Enter, then enter the passphrase (twice) to protect your key from being accessed by anyone else on your computer: without a passphrase it's unencrypted and free for anyone to take and use from that machine.
Once that is done, locate your public key file: id_rsa.pub. Note: not id_rsa, it's a private key, you may not want to give it to anyone, it's much like your future Heroku password, except for it's insanely large for a password. Open id_rsa.pub, you should see stuff like:
ssh-rsa aWhOLELotofUnreadABLEGibbERishWHiCHiSactUALLyYourPubLIcKeY...
You need to enter that line into your account settings in Heroku dashboard, under SSH Keys. You can find more info on keys here, in Heroku docs. Make sure Heroku actually recognizes you by issuing this:
ssh -v git#heroku.com
It should state you're authenticated.
Now for the git address. I assume you know your way around git, so I'll keep it short: you'll need to derive your repository address from your app name. Heroku usually generates weird (yet somewhat poetic) names like falling-wind-1624 or shielded-fjord-1858. I'll take the first one as an example, this is how you add its address as a git remote:
git remote add heroku git#heroku.com:falling-wind-1624.git
I'll explain a bit of it below. So what the toolbelt does here, is to use your app name only, it just builds the URL the same way by adding a path to Heroku server. Once that's done, you should be able to push your code:
git push heroku master
I've named a Heroku remote heroku, above, that's why I'm using heroku name here, you can name it whatever you want and use this afterwards. Once you've pushed the code, the rest is up to you.

Capistrano3 deploy fails after migrating the server

I am using Capistrano 3. In the past I could successfully deploy to my server.
Now the server migrated and has new parameters:
SSH Access (I updated SSH credentials and made sure that I can connect without password using authorized_keys)
Deploy Dir (I updated staging.rb accordingly along with SSH Credentials)
Now cap could connect to my new server so the Auth seemed fine.
Problems with current directory
However, I got an Error when using cap staging deploy:
SSHKit::Command::Failed: if test ! -d /var/www/my-project/subdomains/dev/current; then echo "Directory does not exist '/var/www/my-project/subdomains/dev/current'" 1>&2; false; fi exit status: 1
I checked and the curiously the current directory was still there (migrated along with the rest). I deleted the current directory because this will be created on the deploy (I thought then).
On the next deploy I got the same error. So I did some googling and I ended up adding the following hook:
# Had to insert this hook after migrating the server
# Maybe this can be removed after the first successful deployment
after 'deploy:set_current_revision', 'deploy:symlink:release'
I think this is not a very clean approach but from then on the current directory was created and I got a little farther with cap staging deploy.
Now whenever I setup Capistrano I am amazed how painless it works but now since I have moved to another server I keep running into issues.
I wonder:
Is there a new way to configure the environment in deploy.rb or staging|production.rb respectively?
Do I have to delete existing shared files (e.g. bundler, tmp, pids etc.) or the current directory when I am on a new environment?
I managed to fix my deploy and I am not sure which of the steps I took were really required.
I documented the solution in this SO Post: Bundler in deployment mode does not find Gems

Capistrano Net::SSH::AuthenticationFailed

This is my situation: I have this rails app that I have "capified" and I'm trying to deploy with capistrano onto my Ubuntu cloud server. I have been following this guide -> http://robmclarty.com/blog/how-to-deploy-a-rails-4-app-with-git-and-capistrano
When I run $ cap production deploy, cap aborts and I get the result Net::SSH::AuthenticationFailed.
My guess: My server is not getting access to my bitbucket repo?
Well I have generated an ssh key on my server, added the key in my bitbucket account and also done a git ls-remote git#bitbucket.org:my-username/my-repo.git.
So what am I missing here?
Here's my config/deploy.rb: https://gist.github.com/anonymous/7707266
So my dev computer could not access the production server. It turned out I had put the line server "<server-ip>", user: "depoy-user", roles: %w{web app} in config/deploy.rb. Moving it into config/deploy/production.rb solved my problem. Facepalms, facepalms everywhere.

eval `ssh-agent` for cap deploy

I'm on ubuntu 11.10. When I need to deploy using capistrano, unless I write
eval `ssh-agent`
ssh-add
the deploy process asks for the git repository password as well as the server access password. Can I set something in my terminal config to stop me having to do this?
I think you can able to solve your issue by using ssh public/private key, I think following references helps you to solve it.
capistrano problem, Capistrano asks for password when deploying, despite SSH keys

Resources