Program Tip

heroku 코드를 배포 할 때 권한이 거부되었습니다 (공개 키).

programtip 2020. 9. 28. 09:54
반응형

heroku 코드를 배포 할 때 권한이 거부되었습니다 (공개 키). 치명적 : 원격 끝이 예기치 않게 끊김


다음 명령 줄을 사용하여 내 코드를 heroku에 배포하려고합니다.

git push heroku master

그러나 다음 오류가 발생합니다.

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

이미 공개 SSH 키를 업로드했지만 여전히이 오류가 발생합니다.


공개 키를 Heroku에 업로드해야합니다.

heroku keys:add ~/.ssh/id_rsa.pub

공개 키가없는 경우 Heroku는 원활하게 작동하는 하나를 자동으로 추가하라는 메시지를 표시합니다. 다음을 사용하십시오.

heroku keys:add

이전 키를 모두 지우려면 다음을 수행하십시오.

heroku keys:clear

모든 기존 키를 표시하려면 다음을 수행하십시오.

heroku keys

편집하다:

위의 내용은 저에게 효과적이지 않은 것 같습니다. HOME환경 변수를 엉망으로 만들었 기 때문에 SSH가 잘못된 디렉토리에서 키를 검색했습니다.

SSH가 올바른 디렉토리에서 키를 확인하는지 확인하려면 다음을 수행하십시오.

ssh -vT git@heroku.com

다음 (샘플) 행이 표시됩니다.

OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Connecting to heroku.com [50.19.85.156] port 22.
debug1: Connection established.
debug1: identity file /c/Wrong/Directory/.ssh/identity type -1
debug1: identity file /c/Wrong/Directory/.ssh/id_rsa type -1
debug1: identity file /c/Wrong/Directory/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version Twisted
debug1: no match: Twisted
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'heroku.com' is known and matches the RSA host key.
debug1: Found key in /c/Wrong/Directory/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Wrong/Directory/.ssh/identity
debug1: Trying private key: /c/Wrong/Directory/.ssh/id_rsa
debug1: Trying private key: /c/Wrong/Directory/.ssh/id_dsa
debug1: No more authentication methods to try.

Permission denied (publickey).

위의 내용에서 ssh /c/Wrong/Directory/.ssh가 방금 heroku에 추가 한 공개 키 (사용 heroku keys:add ~/.ssh/id_rsa.pub) 가없는 디렉토리 에서 키를 찾는 것을 볼 수 있습니다 ( Windows OS 에서는 win~HOMEC:\Users\UserName 7/8 에서 경로를 참조합니다. 이다 )

현재 홈 디렉토리를 보려면 다음을 수행하십시오. echo $HOME또는 echo %HOME%(Windows)

HOME디렉토리를 올바르게 설정하려면 (올바르게 디렉토리의 상위 디렉토리를 의미 .ssh하므로 ssh가 올바른 디렉토리에서 키를 찾을 수 있음) 다음 링크를 참조하십시오.

  1. 유닉스 환경 변수를 영구적으로 설정하는 방법에 대한 답변

  2. 그래서 ssh가 잘못된 디렉토리에서 키를 찾고 동일한 솔루션에 관한 질문입니다.


나는 같은 문제가 있었고 아래 단계가 나를 위해 일했습니다.

->heroku login

abc@gmail.com 및 비밀번호

->cd C:\Users\yourusername\.ssh    (OR for cygwin shell ->cd ~/.ssh)

->ssh-keygen -t rsa -f id_rsa

암호를 묻는 경우 공백을 사용하지 말고 암호를 입력하되 잊지 마십시오.

키를 생성 한 후 추가해야합니다.

$ ssh-add

그리고 그것은 heroku에

->heroku keys:add "id_rsa.pub"

디렉토리를 작업 공간으로 변경하십시오.

->git clone git@heroku.com:stark-dawn-1234.git -o heroku

위에서 설정 한 암호를 사용하십시오.


실제로 아래 파일도 제거하지만 그들이 imp인지 확실하지 않습니다.

C : \ Users \ yourusername.heroku \ credientals 및 C : \ Users \ yourusername.ssh \ known_hosts


이 문제는 며칠 동안 나를 엉망으로 만들었습니다.

도움이 될 수 있습니다.

1) 지금 Heroku에 어떤 키가 있는지 알아보십시오.

$ heroku keys
=== 1 key for joe@example.com
ssh-dss AAAAB8NzaC...DVj3R4Ww== joe@workstation.local

2) ~ / .ssh / config 파일을 빌드하십시오.

$ sudo vim ~/.ssh/config

이 정보로 수정

Host heroku.com
Hostname heroku.com 
Port 22 
IdentitiesOnly yes 
IdentityFile ~/.ssh/ssh-dss # location and name of your private key
TCPKeepAlive yes 
User joe@workstation.local

다음은 ssh 키를 관리하는 방법을 설명하는 링크입니다. http://devcenter.heroku.com/articles/keys#adding_keys_to_heroku


나는 공개 키가 없기 때문에 같은 문제가 있었으므로 다음과 같이했습니다.

heroku keys:clear
heroku keys:add

그러면 공개 키가 생성되고 잘 작동합니다.


If you are a windows user the other solutions here probably won't solve your problem.

I use Windows 7 64-Bit + Git-1.7.7.1-preview20111027 and the solution was to copy my keys from C:\users\user\.ssh to C:\Program Files (x86)\Git\.ssh. That's where this git client looks for the keys when pushing to heroku.

I hope this helps.


This was the solution for me:

ssh-add ~/.ssh/my_heroku_key_rsa

To share my experience :

Git (my own install) was looking for the key named 'id_rsa'.

So I tried to rename my keys to 'id_rsa' and 'id_rsa.pub' and it worked.

Btw, I'm sure there is an other way to do it but I didn't look deeper yet.


If you've already uploaded the key then try to remove the key and then re-upload it with a new key.

 heroku keys:remove //removes the existing key
 ssh-keygen -t rsa //generates a new key in ~/.ssh folder
 heroku keys:add    //uploads the new key, if no arguments r passed then the key generated                              
                    //in default directroy i.e., ~/.ssh/id_rsa is uploaded
 git push heroku

this should work.


I killed myself for 3 days trying every possible combination to try to get this to work -- I finally tried making a DSA key instead and it worked.

Try DSA instead of RSA if it's not working for you.

(I'm using Ubuntu 11.10, ruby 1.8.7, heroku 2.15.1)


On Windows 7,64 bit,the above solution (Onur Turhan's) worked for me with slight changes as below

C:\Users\MyName > heroku login

Enter email/password

C:\Users\MyName >ssh-keygen -t rsa -f id_rsa

This generated two files(id_rsa and id_rsa.pub) in my c:\Users\MyName directory (Not in .ssh directory)

heroku keys:add id_rsa.pub
git clone git@heroku.com:some-heiku-xxxx.git -o heroku

I guess adding the correct "id_rsa.pub" file is the most important.After generating the public key using keygen just verify that you are adding correct key by looking at the time-stamp when it was created.


One single command works:

heroku keys:add

It will make one if it doesn't exist.


I had this problem when TortoiseGIT was installed on my machine. After changing the environment variable GIT_SSH from

"c:\Program Files\TortoiseGit\bin\TortoisePlink.exe"

to

"c:\Program Files (x86)\Git\bin\ssh.exe"

and following this tutorial with ssh-keygen and keys:add, it works!


Pushing was working for me and then stopped suddenly.

If the heroku api is experiencing downtime, you will get this error when you try to push.

Check:

https://status.heroku.com/

before freaking out too hard.


Sequence to follow

$ heroku login
$ ssh-keygen -t rsa
$ heroku keys:add

When executing second statement it would ask for input, just press Enter(return) three times and a key will be added.


The above given answer DOES work, but found out I needed to do some extra steps before it worked.

  1. I removed all id_rsa* files and generated a new SSH using this guide.
  2. Then, I destroyed the heroku app. Removed the ~/.heroku/credentials file.
  3. 'heroku create' command (and since the credentials file is removed, it will prompt you for your email/password.
  4. FINALLY type 'heroku keys:add' and it will upload the default ~/.ssh/id_rsa.pub file.
  5. It works! Well.... YMMV but I really do hope this can be some help as I struggled the whole day trying to figure this out! Haha

For all those who tried everything mentioned above on Windows 7 and still it didn't work, here is what I've done: - open GitBash.exe from the Git directory C:\Program Files (x86)\Git\ (don't open a command prompt, this won't work). - add the following as mentioned above, but you have to delete the #

Host heroku.com
Hostname heroku.com 
Port 22 
IdentitiesOnly yes 
IdentityFile ~/.ssh/ssh-dss
TCPKeepAlive yes 
User joe@workstation.local

now run git push heroku master and it should work.


It sounds like your ~/.ssh/authorized_keys file is not set up correctly. Verify that:

  • It is in the correct path.
  • The permissions of the file are 0600.
  • The permissions of ~/.ssh are 0700.

I had to do:

$ ssh-keygen -t rsa  
$ heroku keys:add  

Then it worked:

$ git push heroku master  

Check your .ssh config for heroku. Go to the .ssh folder and open the config file

cd ~/.ssh
subl config

The 'subl' is for Sublime Text, but you can use whatever editor you wish. Look for the line "IdentityFile" and make sure it has the non public key listed:

IdentityFile "/Users/ircmullaney/.ssh/my_ssh"

not

IdentityFile "/Users/ircmullaney/.ssh/my_ssh.pub"

That did it for me. I'm not sure why mine had the public version in the config file, but it did and it was throwing the error:

Permissions 0644 for '/Users/ircmullaney/.ssh/my_ssh.pub' are too open.

I was still having problems after trying all of these ideas. This was my problem:

My remote heroku repository was funked. I refreshed it as follows:

git remote -v

Then remove the heroku one that is wrong:

git remote rm heroku

Then add the new one

git remote add heroku git@heroku.com:sitename.git

You can get the sitename from your Heroku settings page for your app. Good Luck!


The problem I faced was on Windows and invariably whenever I run the "heroku keys:add" it selected the github keys. So here are the steps I followed to resolve the issue

  1. went to the .ssh directory under "Document and Settings" folder and deleted the git hub keys
  2. run the command heroku keys:add

The above command asked me to generate a new keys and following was the output Could not find an existing public key. Would you like to generate one? [Yn] Y Generating new SSH public key. Uploading SSH public key C:/Documents and Settings/Admin/.ssh/id_rsa.pub... done ! The 'heroku' gem has been deprecated and replaced with the Heroku Toolbelt, download and install from https://toolbelt.heroku.com.

  1. rerun the command heroku keys:add

The above command will not give the following output Found existing public key: C:/Documents and Settings/Admin/.ssh/id_rsa.pub Uploading SSH public key C:/Documents and Settings/Admin/.ssh/id_rsa.pub... done

  1. Now use the git push heroku master

for me using the above steps solved the issue and was able to deploy the application on the cloud.


I was experiencing the same problem; following these steps should help:

  1. First, log in: heroku login
  2. Clear all keys: heroku keys:clear
  3. Delete all files in local folder ( all .pub files and know_host) in .ssh/ folder
  4. Log in again : heroku login - u will prompt with no key, so follow the onscreen instructions.

I would just to like to add that the directory is not necessarily C:\Users\[username]\.ssh. It is the directory in which you created your public key in.

For instance my home directory in Windows was changed to C:\[username]. Your home directory in a .ssh sub-folder is the best and most likely place you may have created your keys. You can check your home directory in Windows with the command:

    echo %HOMEPATH%

If you want to use "sudo", example:

sudo git clone git@heroku.com......... -o heroku

you should also generate ssh key for your root user.

sudo su
cd /root/.ssh  
ssh-keygen -t rsa
....
heroku keys:add id_rsa.pub

and it'll work.

if you don't use root user, generate ssh key in your user directory instead.

cd /home/user/.ssh

Sorry if my sentences messed up...


Try repairing permissions in Disk Utility (Mac OS X). Helped me


At first make sure hidden files are visible in your Mac. If not do:

  • Open terminal and type in defaults write com.apple.Finder AppleShowAllFiles TRUE
  • killall Finder

Next steps:

  • Going to Users/user_name/.ssh/ removed all the files.
  • Opening terminal type in ssh-keygen -t dsa
  • Then heroku keys:add ~/.ssh/id_dsa.pub

N.B. I did it in Mac OSX 10.7.2 Lion. Though the procedure should be same in others too.


I have this issue as well. I am using Mac OSX. The way I fixed that was to login as admin

sudo su

password


Solution of dmajkic help me at last:

For Windows users it may means: git client coudn’t find your keys. Check keys in c:\Users\UserName.ssh\ and! environment variable HOME=c:\Users\UserName\


Here is what worked for me. The heroku site is not being added to your known hosts. Go to window-other- show view-git-git repositories. From there clone the repository. Once you clone it, delete the repository that was just created and then import it from the file menu. Do this since when you clone the repository, it does not add it to the explorer view. Now you should have the git repository and the explorer view.

참고URL : https://stackoverflow.com/questions/4269922/permission-denied-publickey-when-deploying-heroku-code-fatal-the-remote-end

반응형