git push heroku master permission denied

前端 未结 7 1961
有刺的猬
有刺的猬 2021-01-31 02:04

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          


        
相关标签:
7条回答
  • 2021-01-31 02:18

    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:

    1. delete your user's .ssh dir
    2. open git-bash
    3. ssh-keygen -t rsa
    4. heroku keys:add

    and then you will be able to git push.

    0 讨论(0)
  • 2021-01-31 02:19

    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.

    1. 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).

    2. 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.

    3. In the bash window enter ssh-keygen -t rsa -C "yourname@email.com" When prompted enter a passphrase (don't lose this).

    4. Close the bash shell window.

    5. 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.

    0 讨论(0)
  • 2021-01-31 02:20

    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
    
    0 讨论(0)
  • 2021-01-31 02:28
    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.

    0 讨论(0)
  • 2021-01-31 02:40

    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 :)

    0 讨论(0)
  • 2021-01-31 02:41

    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
    
    0 讨论(0)
提交回复
热议问题