Has anyone successfully deployed on heroku from a windows platform? - ruby-on-rails

I've been reading all kinds of tutorials on how to deploy rails apps on heroku from windows.
I've tried installing git, heroku gem, generating ssh keys and setting paths and everything...
I get either public key error (without putty) or fatal no auth found (with putty)...

After some setup problems -- indeed related to SSH keys -- I've successfully developed Rails/Sinatra applications on Windows and deployed those to Heroku. It works fine.
Generating the keys was a challenge -- I didn't keep notes, but I think I generated the keys with the Git GUI in which you can create a OpenSSH key. That key file is stored in ~/.ssh (so within C:\Documents and Settings\<account>\.ssh) as id_rsa with an accompanying id_rsa.pub. Since I wanted a seperate key for use in Heroku, I've renamed both files of the key pair to id_heroku / id_heroku.pub.
Finally, in the same folder, I've created a file config. That file contains
Host heroku.com
Hostname heroku.com
Port 22
IdentitiesOnly yes
IdentityFile ~/.ssh/id_heroku
TCPKeepAlive yes
User user#example.com

Alternately, you may utilize puTTYgen.exe , and paste the OpenSSH public key into a mykey.pub file, and uploading that with heroku keys:add c:\mykey.pub

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't access my Heroku repo even though I've added my key

I'm trying to clone a current project from Heroku. I was having permission access issues so I removed existing keys, and added my current key:
$ heroku keys:add
Found an SSH public key at /home/martyn/.ssh/id_rsa.pub
Would you like to upload it to Heroku? [Yn] Y
Uploading SSH public key /home/martyn/.ssh/id_rsa.pub... done
$ heroku keys
=== martynbissett#yahoo.co.uk Keys
ssh-rsa AAAAB3NzaC...5VRkk6UVBT martyn#martyn-Lenovo-B590
$ heroku git:clone -a young-lowlands-8336
Cloning from app 'young-lowlands-8336'...
Cloning into 'young-lowlands-8336'...
Agent admitted failure to sign using the key.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I've check the site is live, and it is. From my Heroku control panel I can see that this project is active too. Why am I still being denied?
This is the response I got back from Heroku, and it seems to work now:
It looks like your local SSH is using a different key than the default one.
Could you try resetting your keys identities to the default with the following command:
ssh-add -D

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.

Heroku Deployment from multiple win7 64 machines

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

Heroku Create: Could not read from remote repository

Trying to deploy my first Rails app to Heroku.
All app code is here:
https://github.com/donpinkus/first_app.
Running heroku create gives me this error:
donaldmbp15:first_app donald$ git push heroku master
Warning: Permanently added the RSA host key for IP address '50.19.85.132' to the list of known hosts.
Connection closed by 50.19.85.132
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
donaldmbp15:first_app donald$
It sounds like something along the line, either Heroku or Github does not have access rights. I've pushed to Github from my local git repo, so I'm ruling out Github as the source of error. That leaves Heroku, or my local machine. Any ideas?
First Generate the RSA key first by following
bash: ssh-keygen -t rsa
Add your key to heroku
bash: heroku keys:add
Read more https://devcenter.heroku.com/articles/keys

Resources