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
Related
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.
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.
First of all, I read this question but I still have problems with deploying from multiple machines.
From work everything works like a charm, but from home-machine I have problem pushing to same Heroku app. Both machines are Win7 64, IDE is Rubymine (jumping between integrated git gui and terminal - but no problems with that), Ruby200 and devkit both 32 and 64 (but on separate machines), .ssh keys in C:/users/.ssh/ (on both machines). Git stuff is also working like a charm on both machines. Same heroku acc.
On home machine when I $ heroku keys it lists 2 keys like it should (for work and home machine). Then when I $ git remote add heroku git#heroku.com:my-app.git I get fatal saying that I already have that remote repository on this machine. I check for remotes $ git remote -v and it lists 2 reps (both github and heroku), like it should, but when I $ git push heroku I get:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I tried deleting keys, generating new ones both with ssh-keygen -t rsa and heroku keys:add to create after previously removing one and with no luck. Even added it with heroku keys:add C:/path-to-ssh.pub if that specificity even mater.
I know that I can 'cheat' this out with DropBox but I'd rather avoid them and go this way, pulling from Github. Thank you in advance, if more info is needed I will provide it.
Edit: I tried $ heroku create project-with-another-name to create heroku app with same code and it goes through. After I check for that remote via $ git remote -v I don't see it (only old ones), but when I tried to add it with $ git remote add heroku ..., it said to me that remote allready exist and I can see it in Heroku dashboard. $ git push heroku master gives me same error as before.
The problem seems to be an issue with the local git repos on your system, and how they communicate with the remote Heroku repo.
The issue will either be with the ssh keys on your system, or the remote repos your computer will have (and how you're able to communicate with Heroku properly).
--
Fix
After looking at this question, you may wish to use the following:
Really all I had to do was follow these steps:
https://devcenter.heroku.com/articles/keys
First you have to create a key:
ssh-keygen -t rsa
Second you have to add the key to Heroku:
heroku keys:add
--
If that doesn't work, I would get rid of the local git repo & then create a new remote one for use with Heroku:
delete the .git repo for your local app
In the parent / apps directory, run git init [folder_name]
Inside the app folder directly, you can then run git#heroku.com:project.git
Solution:
# Generate key
ssh-keygen -t rsa
# Start of ssh-agent (I missed this step and
# it didn't added key to my machine even though it
# created file. In order to do: ssh-add C:/path/to/id_rsa_key
# I needed to start ssh-agent)
eval $(ssh-agent)
# Then add private key
ssh-add C:/path/to/id_rsa_key
cd C:/project
# And finaly send public key to heroku
heroku keys:add C:/path/to/id_rsa_key.pub
This is my first time using linode and uploading a Rails app to a VPS, so I might of skipped something obvious.
I followed two tutorials
Ryan Bates video to deploying to a vps
and
David's answer on Stackoverflow
I am at the point where I want to deploy my rails app on Linode (Ubuntu 13.10)
When I execute the command bundle exec cap deploy:update
I get the errors that Linode cannot connect to github due to a public key
user:my-app User$ bundle exec cap deploy:update
* 2014-02-12 17:19:46 executing `deploy:update'
** transaction: start
* 2014-02-12 17:19:46 executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote git#github.com:user/my-app.git master"
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
*** [deploy:update_code] rolling back
* executing "rm -rf /home/user/apps/my-app/releases/20140212091953; true"
servers: ["XXX.XXX.XX.XX"]
[XXX.XXX.XX.XX] executing command
command finished in 4607ms
Command git ls-remote git#github.com:user/my-app.git master returned status code pid 1529 exit 128
On my local machine I have no problem to commit and push my app on Github and I have RSA Keys on my local computer. It just asks me to login with my username and password each time I push my app.
On linode from the shell, I can connect to github by using ssh -vT git#github.com. I do have the RSA keys on the linode server and I added the ssh-agent using ssh-add
my deploy.rb
set :application, "my-app"
set :user, "user"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :keep_releases, 3
default_run_options[:pty] = true
set :scm, :git
set :repository, "git#github.com:user/#{application}.git"
set :ssh_options, { :forward_agent => true }
# ssh_options[:forward_agent] = true
set :branch, "master"
I am a bit at a loss.
EDIT: I have a private repository
I just moved from Linux to Mac OSx. Thus, I have imported whole .ssh folder from linux to mac. While moving from linux to linux it worked, but to make it work on Mac, I had also to run:
ssh-add
That's the whole fix ;) See http://peteoliveira.com/deploying-with-capistrano-3-failing-permission-denied-publickey/ for more info.
So I found the solution to this github connection. I actually have another problem with the deployment where the bundle install fails. Anyways here is what I learned and I hope it will help others.
What you need to know:
With Capistrano when you wish to push your public or private Github
repository onto your VPS server, you need to make sure that BOTH your
server and your computer has an SSH access with Github.
Even if you can git push origin master it doesn't mean you have SSH
access with Github. Here is how you troubleshoot:
A) Make sure you can SSH access from your computer
Make sure you have Git installed on your machine Set up Git
tutorial
Make sure that you have an SSH Key on your local machine (with Linux
or Mac)
cd ~/.ssh then
ls -a
and look for the files id_rsa and id_rsa.pub
If you don't have these rsa files, follow this tutorial
Generating SSH keys
Copy your SSH key
pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
Login with your browser on http://www.github.com and go to
your_username -> edit profile -> settings -> ssh keys
https://github.com/settings/ssh. Click the button Add keys, add the name that identifies your comptuter and paste the key code that you previously copied.
Make sure you have SSH Agent on. In Terminal type
ssh-add #enter a passphrase if you want to (recommended)
Test if you can SSH with Github
ssh git#github.com
The first time it may ask you to accept the connection.
You should get the following response
PTY allocation request failed on channel 0
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
You can also make sure that your id_rsa is properly found by running
ssh -vT git#github.com
# make sure that this line is not -1 (it means it couldn't find the file)
=> debug1: identity file /Users/YOUR_USERNAME/.ssh/id_rsa type 1
Now you shouldn't have permission denied (Public Key)
B) Make sure you can SSH access from your server
Run ssh root#your_server_ip_address if you didn't setup a user on your server or ssh username#your_server_ip_address. You will then be within the server shell and you want to repeat the same process for your computer.
NOTE: The server SSH Keys will be different than your computer. That means that on Github you need to add 2 SSH Keys, one for your computer and one for your server. That is why you need to repeat the process on both machines. Also to keep it simple, do not try to have more than one SSH Key on each machine.
NOTE 2: In your server after you generated your SSH key, to copy it run the command cat ~/.ssh/id_rsa.pub
Once both your computer and the server are accepted on Github, then you can update your rails app using capistrano and your Github repository. Yay!
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.