Heroku 错误: “权限被拒绝(公钥)”

我一直得到这个错误。我正在使用 Mac。我生成了一个密钥,并添加到 heroku 使用

heroku config:add key="ssh-rsa blahblah=me@me.com"

但是这不工作。我一直得到相同的错误。除了重新安装 ssh-keygen,我能做些什么呢?

32671 次浏览

Try heroku keys:add <path-to-your-public-key>.

For example, heroku keys:add ~/.ssh/id_rsa.pub

This could also indicate API issues. Make sure to check https://status.heroku.com

the solution above did not work for me as I did not have any keys generated in my ~/.ssh folder.

My solution was to simply type heroku keys:add

The output in terminal was:

Could not find an existing public key.
Would you like to generate one? [Yn] y
Generating new SSH public key.
Uploading SSH public key /home/funkdified/.ssh/id_rsa.pub... done

See: https://devcenter.heroku.com/articles/keys

i faced the same issue . Writing my experience so it helps someone else .

I tried to follow the instructions that were detialed on the official website -Getting Started with Your Facebook App on Heroku

Even though it is quite detialed especially the video it is quite annoying to note that they do not mention having to set up SSH keys . Either it is set by default ( i dont know ) or you get the error mentioned by the question poster .

So i did the following :

1 . opened up the git shell

2 . typed the following in

C:\Users\blue\Documents\GitHub> heroku keys:add
Found the following SSH public keys:
1) github_rsa.pub
2) id_rsa.pub
Which would you like to use with your Heroku account? 2

3 . Subsequent to this i was able to getcheckout my repository

C:\Users\blue\Documents\GitHub> heroku login
Enter your Heroku credentials.
Email: sxxxxt.xxxx@gmail.com
Password (typing will be hidden):
Authentication successful.
C:\Users\blue\Documents\GitHub> git clone git@heroku.com:sxxxd-plains-8530.gi
t
Cloning into 'sxxxd-plains-8530'...
Warning: Permanently added 'heroku.com,50.19.85.154' (RSA) to the list of known
hosts.
remote: Counting objects: 180, done.
remote: Compressing objects: 100% (112/112), done.
remote: Total 180 (delta 82), reused 132 (delta 62)
Receiving objects:  81% (146/180), 76.00 KiB | 62 KiB/s
Receiving objects: 100% (180/180), 137.91 KiB | 62 KiB/s, done.
Resolving deltas: 100% (82/82), done.
C:\Users\blue\Documents\GitHub>

Please dont downvote my answer . Even though i dont add any new value to what is already posted but i hope my experiences will help someone who is new to using git & heruko . Hence i added screen shots .

  • My 2 cents

if you dont have ssh key yet then try generating it using below command :

1. ssh-keygen -t rsa -C "your_email@example.com"
2. ssh-add

For getting rid of heroku permission denied (public key) add your keys to heroku using:

3. heroku keys:add <path_to_your_ssh>
OR
heroku keys:add

For getting rid of Github permission denied (public key) add your keys to Github using:

4. ssh-add <path_to_your_ssh>
OR
ssh-add

Copy the files in your .ssh path ex:

/c/Users/<yourusername>/.ssh/<files>

to the git .ssh folder.

/c/Program Files/Git/.ssh/<paste files here>

If the .ssh folder doesn't exist in the Git directory simply create it then paste your files.

For some reason windows require that a .ssh path be in the user directory as well as the Git directory. ON default this is not added so you simply have to create it yourself.

After adding the files to Git's directory simply run the following command again:

git push heroku master