Upload site on Heroku: Host key verification failed - ruby-on-rails

The first time I unloaded a site on Heroku I faced many mistakes. How to correct?
k#k-Aspire-5750G:~/q$ git clone git#github.com:priroda/programmer-site
Cloning into 'programmer-site'...
The authenticity of host 'github.com (192.30.252.131)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
Host key verification failed.
fatal: The remote end hung up unexpectedly
I have 2 files in directory ssh:
k#k-Aspire-5750G:~/.ssh$ ls
id_rsa id_rsa.pub

ssh
Your problem here looks like you're trying to ssh into heroku and clone your repo directly from github?
The problem here is that if you connect to github through ssh (a third party), you will basically have to create an authenticity token (ssh key), so that your third party machine is able to connect to your github repo
--
Fix
Typically, your local machine will be authenticated anyway when you install git, heroku not so. I would therefore recommend you push to Heroku from your local machine, rather than trying to clone through github:
$ git remote add heroku git#heroku.com
$ git add .
$ git commit -a -m "Heroku Deploy"
$ git push heroku master
If you do this first time, you will likely come back with some sort of request for your ssh to be accepted or something - just accept & it should push to Heroku from your local machine
Here is Heroku's take on the matter

Your output looks like a problem with your host verification with Github.com when you're trying to clone and nothing to do with Heroku.
Have a look in your ~/.ssh/known_hosts for a github.com entry and highlight it and remove it. Then try your clone again and it will prompt to verify, say yes and then it should clone successfully.

Related

Heroku Without Toolbelt On Windows

Would like to be able to push to, and clone from, Heroku without the toolbelt.
I've got Win10x64, Rails 2.4.4, Ruby 2.2.3
The answer is to link to Heroku using ssh:
You need to download & install git
You need to generate your SSH key
You need to "link" your Heroku app to your computer's SSH key
You should then be able to push/clone from Heroku
--
This answer helped get it working:
https://serverfault.com/a/198709/241166
You have to set the HOME path of your ssh before performing ssh-keygen -t rsa (this actually doesn't seem to be the case; you should be able to browse to the required output folder & run ssh-keygen -t rsa):
ssh has its keys in c:/Users/[username]/.ssh by default.
This will set the .pub file, which you'll be able to open using a text editor (notepad will do):
You then need to copy the contents of the generated .pub file to Heroku's Account Settings option:
If you need to remove Heroku from known_hosts, you'll want to use:
ssh-keygen -H -F heroku.com
ssh-keygen -R heroku.com
--
Next, you need to authenticate with Heroku.
ssh -v git#heroku.com
This should then allow you to connect via SSH to Heroku from that system.
It may say a permission denied error - you should be able to ignore that, cd to the folder where the git repo is stored, and perform push / commit:
That's how to connect via SSH to Heroku on Windows :)

Bitbucket/Github: permission denied public key

when I am trying to clone a rails app repo I have got permission to, I am getting this issue.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Even after adding public key by generating one, I am unable to solve this.
Although I am able to clone using he https method but after making changes, the same error comes while I try to push the code.
Please suggest an answer for this.
First, cd into your .ssh directory. Open up the terminal and run:
cd ~/.ssh && ssh-keygen
Second, you need to copy this to your clipboard:
cat id_rsa.pub | pbcopy # On OSX
cat id_rsa.pub | xclip # On Linux
Third, add your newly generated ssh key to your account via the github/bitbucket website (just paste there).
Next, setup your git config:
git config --global user.name 'your_user_name'
git config --global user.email 'your_email'
Finally, restart your command line to make sure the config is reloaded.
Now, you should be able to clone and push from/to your github repository.
For more information on this, see this github page or this bitbucket page.
When attempting to clone, push, or pull over SSH with Git, you may receive one of these messages if Bitbucket couldn't authenticate with the keys that your SSH agent offered.
Here are the most common reasons why you may see these messages:
You used sudo when attempting the connection
You shouldn't use sudo when cloning, pushing, or pulling because the ssh-agent runs on the user level, not the root level.
Your public key isn't loaded into Bitbucket
To check if your public key is loaded into Bitbucket, do the following:
From Bitbucket, choose Personal settings from your avatar in the lower left.
The Account settings page displays.
Click SSH keys.
The SSH keys page shows a list of any existing keys.
If you don't have any keys listed, you can follow our Set up an SSH key documentation to set one up.
Your key isn't loaded into your SSH agent
If your SSH agent doesn't know to offer Bitbucket a key, the connection fails. You may run into this issue if you've recently restarted your system.
You can refer to this Article for more informations:
https://support.atlassian.com/bitbucket-cloud/docs/troubleshoot-ssh-issues/
Check few things.
Is the generated new key is the one your ssh agent using when trying to ssh to server.
(Your ssh agent might be using a different key than the one you generated)
use this to list currently loaded keys by agent.
ssh-add -L
You properly added public key to your repository hosting location.
The keys corresponding to above 1 and 2 should match.
Please see this article: GitHub: Generating SSH Keys. What happens when you run:
ssh -T git#bitbucket.org
?
You may have added the wrong key to authenticate with.
I faced this error when I created another repository in my local. My ssh-keys were already set up and I was trying to push code through vs code.
The issue got resolved when I git push-ed through git bash like I was doing before.
For bit bucket I think I have tried everything with ssh. I have tried the answer from this stackoverflow question as well. But it doesn't work. So finally I just changed the clone command from SSH to HTTPS and it worked. Only then it asked for password for my account.

Unable to negotiate a key exchange method with Mina deployment

I'm encountering a message like this while deploying with Mina, but not sure why Git is not able to pull the repo.
I've tried switching sshd_config due to Unable to negotiate a key exchange method message, but still can't figure things out. Thanks for helping.
-----> Creating a temporary build path
$ touch "deploy.lock"
$ mkdir -p "$build_path"
$ cd "$build_path"
-----> Cloning the Git repository
$ git clone "git#github.com:repo/project.git" "/home/deploy/project/scm" --bare
Cloning into bare repository '/home/deploy/project/scm'...
Unable to negotiate a key exchange method
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
! ERROR: Deploy failed.
-----> Cleaning up build
$ rm -rf "$build_path"
Unlinking current
$ rm -f "deploy.lock"
OK
! Command failed.
Failed with status 1 (19)
The issue is, that your local SSH client and the remote endpoint at GitHub are unable to agree on a common key exchange method.
This will mostly occur when you poked around with the set of available Key exchange methods or you are using a very old & outdated SSH client which does not support any method which is still regarded as safe.
Interestingly this only occurs on some GitHub Repos: I'm still able to pull from other reports.
To diagnose you can set the following environment variable to see more of the SSH output:
export GIT_SSH_COMMAND="ssh -vv"
To fix it, I added a custom entry in my config_ssh or ~/.ssh/.config allowing more legacy algorithms for that host. Please note this should appear above any Host * section:
# Github needs diffie-hellman-group-exchange-sha1 some of the
# time but not always.
Host github.com
KexAlgorithms curve25519-sha256#libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1

git push heroku master permission denied

I am following the ruby.railstutorial. I run the command "git push heroku master" and it spits out this error.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I am inside my rails app "/Users/lexi87/rails_projects/first_app". Any solutions?
The best way to avoid such errors is to use one public/private key pair and not an extra key for heroku. This way you (or your system) can't choose a wrong key to login in heroku.
If you get this error, you have done something wrong. Check this site: https://devcenter.heroku.com/articles/keys
If you geht this error, the best way is to remove unnecessary keys and use only one.
If you need more than one key pair on your system, you can set one key for heroku. This is done through the following command:
heroku keys:add
Some help for Windows 7 users with Github Windows client installed:
Even though heroku toolbelt reports it found my git_hub public key and uploaded it, 'git push heroku master' failed. After taking the steps below, it works fine.
Create .ssh folder under your User folder if one does not exist. If
it does, delete all files in it (this assumes you are OK with starting from scratch with ssh keys).
In Windows Explorer, right click the
.ssh folder, and choose Git bash from the context menu. This is installed along with the Github Windows client software.
In the bash window enter
ssh-keygen -t rsa -C "yourname#email.com" When prompted enter a
passphrase (don't lose this).
Close the bash shell window.
From a cmd prompt in your project's root, enter heroku keys:add.
This will find and upload the key you just created from your /.ssh file to
Heroku.
Now you can enter git push heroku master to push you app up to Heroku.
Note: you will need to add your newly generated ssh public key to your Github account when done.
I faced the same issue. In my .ssh folder I had a file called 'Known Hosts'. I kept trying to delete and create new ssh keys it did not work. In the end I just deleted everything in .ssh including 'Known Hosts' and then created a new rsa key using:
ssh-keygen -t rsa
then I added this new key to heroku using:
heroku keys:add
then create a new heroku repo and pushed my app to it:
heroku create
git push heroku master
ssh-keygen -t rsa
Above is optional as you could also link to an existing key. Heroku will prompt to select the key in the next step.
heroku keys:add
Add your newly created key or an existing one. If you are still running into the issue, you will most likely need to add the key to your machine's list of ssh keys by performing the following:
ssh-add ~/.ssh/name_of_your_rsa
and confirm that your ssh has been added
ssh-add -l
This should get you access to push to Heroku's remote repo.
on OSX, I was having experiencing the same issue, I was getting
no such identity: /Users/me/.ssh/yourPrivateKey: No such file or directory
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 to create a new key with ssh-keygen -t rsa then adding it with heroku keys:add, but it didn't help.
Then I found a file named config in ~/.ssh/, and inside the file there was:
ServerAliveInterval 300
ServerAliveCountMax 3
host heroku.com
user git
hostname heroku.com
identityfile ~/.ssh/yourPrivateKey
So I changed yourPrivateKey to my private key filename (id_rsa by default) aaand it worked :)
I created a key with
ssh-keygen -t rsa
and used a different filename than id_rsa (in my case heroku). I added the key to heroku with
heroku keys:add
On trying to push my master branch to heroku I always received the following error:
$ git push heroku master
The authenticity of host 'heroku.com
(50.19.85.132)' can't be established. RSA key fingerprint is
8b:48:5e:67:0e:c9:16:47:32:99:87:0c:1f:c8:60:bb. Are you sure you want
to continue connecting (yes/no)? yes Warning: Permanently added
'heroku.com,50.19.85.132' (RSA) to the list of known hosts. Permission
denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository
exists.
As I noticed git only used my id_rsa key from another ssh-access (you can check that via your git gui: Help -> SSH keys).
I renamed my .ssh directory C:\Users\%username%.ssh to .ssh.bak and copied my heroku private and public key (from the .ssh.bak directory) to a newly created .ssh directory and named it id_rsa (and id_rsa.pub).
Now pushing worked as expected:
git push heroku master
If you are working on Windows, be sure to use git-bash instead of Powershell/Command Prompt.
If you just want to reset your ssh keys:
delete your user's .ssh dir
open git-bash
ssh-keygen -t rsa
heroku keys:add
and then you will be able to git push.

git remote push : Permission denied (publickey,keyboard-interactive)

I have been trying to set up a staging machine to run project at home (rails application).
# Remote machine connection
REPLOGIN=joel
REPADDRESS=192.168.2.100
REPLOCATION=/Users/joel/Projects/bio_watts #Repo location
REPNAME=biowatts
# Copy the repo to the server
echo "Copying the git repo to the server $REPADDRESS"
echo "repname:$REPNAME"
TEMPREP="$REPNAME.git"
echo "$TEMPREP"
git clone --bare .git $TEMPREP
scp -r $TEMPREP $REPLOGIN#$REPADDRESS:$REPLOCATION/
# Set up the origin for the project
#echo "Linking current repository to remote repository"
git remote add imac $REPLOGIN#$REPADDRESS:$REPLOCATION/$REPNAME.git/
All this worked fine
$git remote
imac <== this is my remote machine
When I try to git push to this machine I get:
Permission denied (publickey,keyboard-interactive).
fatal: The remote end hung up unexpectedly
I know there is something about SSH ... but I don't understand what I need to do on my local and on my remote machines (Mac OS X Lion).
Can someone help?
Cheers,
Joel
NEXT QUESTION:
On my remote machine I do find my cloned biowatts.git file ... but I don't see the project files (rails app) ... how does it work?
My intent is to git push to my imac and run my app there (thin start) ???
Do I need to copy my file manually? I assumed that the git clone would copy every I needed ...
Your remote git server should know your machine via your iMac's public ssh key and should have a config somewhere allowing you to push (write rights).
That remote machine needs to know about your ssh keys.
You need to generate a key locally (if you don't have one) and then add the public key to the remote server's ~/.ssh/authorized_keys
You can follow the GitHub tutorial on setting up keys (if you don't already have them set up).
http://help.github.com/mac-set-up-git/
Instead of Step 4. Add your SSH key to GitHub, you'll need to add your key to the authorized_keys file on the server.
In the future, for those of you encountering this in assembla specifically, the solution is to copy your ~/.ssh/id_rsa.pub to the assembla profile. This post gives step by step instructions.

Resources