Git Bash : 인증 에이전트에 대한 연결을 열 수 없습니다.
이 질문에 이미 답변이 있습니다.
나는 Github를 처음 사용하고 SSH 키 생성이 필요합니다. 상사로부터이 사실을 알게 되었기 때문에 준수해야합니다.
SSH 키를 성공적으로 생성했지만 ssh-agent에 추가 할 때
이것이 일어나는 일입니다
무엇이 문제인 것 같습니까?
ssh-agent
사용하기 전에 실행해야하는 것 같습니다 .
eval `ssh-agent -s`
이 질문에 대한 답변은 인증 에이전트에 대한 연결을 열 수 없습니다 .
이 게시물의 모든 솔루션과 @kenorb가 위에서 언급 한 게시물을 확인했지만 저에게 맞는 솔루션을 찾지 못했습니다.
다음 구성으로 Windows 7에서 Git 1.9.5 Preview를 사용하고 있습니다.-Windows 명령 프롬프트에서 Git 실행-Windows 스타일 체크 아웃, Unix 스타일 줄 끝 커밋
나는 모든 것에 ' Git Bash '콘솔을 사용했다 . 그리고 SSH 키를 설치하기 전까지는 모든 것이 잘되었다 . GitHub의 문서에는 다음을 수행하라고 나와 있습니다 (게시물 읽기를 마칠 때까지 이러한 명령을 실행하지 마십시오) .
ssh-agent가 활성화되어 있는지 확인합니다.
Git Bash를 사용하는 경우 ssh-agent를 켜십시오.msysgit과 같은 다른 터미널 프롬프트를 사용하는 경우 ssh-agent를 켜십시오.# start the ssh-agent in the background ssh-agent -s # Agent pid 59566
# start the ssh-agent in the background eval $(ssh-agent -s) # Agent pid 59566
물론 저는 당신이 둘 중 하나를해야한다는 사실을 놓쳤습니다. 그래서 나중에 ssh-add
명령이 실패 했기 때문에이 명령을 여러 번 실행 했으므로이 단계로 돌아가서 계속해서 다시 시도했습니다.
이로 인해이 명령을 실행할 때마다 1 개의 Windows 'ssh-agent'프로세스가 생성됩니다 (해당 명령을 입력 할 때마다 새 PID가 표시됩니까?).
따라서 Ctrl
+ Alt
+ Del
를 누르고 End Process
각 ' ssh-agent.exe '프로세스 를 중지 합니다.
이제 실패한 시도로 인해 엉망이 된 모든 것을 정리 했으므로 작동하는 방법을 알려 드리겠습니다.
' Git Bash '에서 :
' ssh-agent.exe '프로세스 시작
eval $(ssh-agent -s)
그리고 SSH 키를 설치하십시오.
ssh-add "C:\Users\MyName\.ssh\id_rsa"
* 위의 경로를 사용자 이름으로 조정하고 * /.ssh 디렉토리 의 위치가 올바른 위치에 있는지 확인하십시오 . Git 설치 중에이 위치를 선택했다고 생각하십니까? 아마...
내가 이것을 알아 내기 전에 내가 잘못하고 있었던 부분은 ' ssh-add '위치 주변에 따옴표를 사용하지 않았다는 것 입니다. 위는 Windows에서 입력하는 방법입니다.
Windows에서는 아래 명령 중 하나와 함께 실행 을 사용할 수 있습니다 .
32 비트의 경우 :
"C : \ Program Files (x86) \ Git \ cmd \ start-ssh-agent.cmd"
64 비트 용 :
"C : \ Program Files \ Git \ cmd \ start-ssh-agent.cmd"
상황 : MVS2017 앱-Windows 10에서 'Git Bash'사용-BitBucket 저장소에 연결을 시도합니다.
To be clear, when you install Git for Windows (https://git-scm.com/download/win), it comes with an utility called Git Bash.
So, I am in 'Git Bash', as follows:
Mike@DUBLIN MINGW64 ~/source/repos/DoubleIrish (master)
$ git remote add origin git@bitbucket.org:Guiness/DoubleIrish.git
$ git remote -v
origin git@bitbucket.org:Guiness/DoubleIrish.git (fetch)
origin git@bitbucket.org:Guiness/DoubleIrish.git (push)
Mike@DUBLIN MINGW64 ~/source/repos/DoubleIrish (master)
$ git push -u origin master
[...]
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.
Is the private key set up?
$ ssh -V
OpenSSH_7.7p1, OpenSSL 1.0.2p 14 Aug 2018
$ ls -a ~/.ssh
./ ../ known_hosts
I can see that, at this point, my private key file (id_rsa
) is missing. So I add it: (note: generating a pair of private-public keys is out of scope of my reply, but I can say that in Linux, you can use ssh-keygen
for that.)
$ ls -a ~/.ssh
./ ../ id_rsa known_hosts
OK, let's proceed:
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-KhQwFLAgWGYC/agent.18320; export SSH_AUTH_SOCK;
SSH_AGENT_PID=17996; export SSH_AGENT_PID;
echo Agent pid 17996;
$ ssh-add ~/.ssh/id_rsa
Could not open a connection to your authentication agent.
To solve this, I run:
$ ssh-agent bash
And then, again:
$ ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/Mike.CORP/.ssh/id_rsa (/c/Users/Mike.CORP/.ssh/id_rsa)
It worked for me. Hope this helps
I was struggling with the problem as well.
After I typed $ eval 'ssh-agent -s' followed by $ssh-add ~/.ssh/id_rsa
I got the same complain: "Could not open a connection to your authentication agent". Then I realize there are two different kind of quotation on my computer's keyboard. So I tried the one at the same position as "~": $ eval ssh-agent -s
$ ssh-add ~/.ssh/id_rsa
And bang it worked.
I would like to improve on the accepted answer
Downsides of using .bashrc
with eval ssh-agent -s
:
- Every git-bash will have it's own ssh-agent.exe process
- SSH key should be manually added every time you open git-bash
Here is my .bashrc
that will eradicate above downsides
Put this .bashrc
into your home directory (Windows 10: C:\Users\[username]\.bashrc
) and it will be executed every time a new git-bash is opened and ssh-add
will be working as a first class citizen
Read #comments to understand how it works
# Env vars used
# SSH_AUTH_SOCK - ssh-agent socket, should be set for ssh-add or git to be able to connect
# SSH_AGENT_PID - ssh-agent process id, should be set in order to check that it is running
# SSH_AGENT_ENV - env file path to share variable between instances of git-bash
SSH_AGENT_ENV=~/ssh-agent.env
# import env file and supress error message if it does not exist
. $SSH_AGENT_ENV 2> /dev/null
# if we know that ssh-agent was launched before ($SSH_AGENT_PID is set) and process with that pid is running
if [ -n "$SSH_AGENT_PID" ] && ps -p $SSH_AGENT_PID > /dev/null
then
# we don't need to do anything, ssh-add and git will properly connect since we've imported env variables required
echo "Connected to ssh-agent"
else
# start ssh-agent and save required vars for sharing in $SSH_AGENT_ENV file
eval $(ssh-agent) > /dev/null
echo export SSH_AUTH_SOCK=\"$SSH_AUTH_SOCK\" > $SSH_AGENT_ENV
echo export SSH_AGENT_PID=$SSH_AGENT_PID >> $SSH_AGENT_ENV
echo "Started ssh-agent"
fi
Also this script uses a little trick to ensure that provided environment variables are shared between git-bash instances by saving them into an .env
file.
above solution doesn't work for me for unknown reason. below is my workaround which was worked successfully.
1) DO NOT generate a new ssh key by using command ssh-keygen -t rsa -C"xxx@xx.com"
, you can delete existing SSH keys.
2) but use Git GUI, -> "Help" -> "Show ssh key" -> "Generate key", the key will saved to ssh automatically and no need to use ssh-add
anymore.
Try using cygwin instead of bash. that worked for me
'Programing' 카테고리의 다른 글
성능 저하없이 UITableView의 원형 UIImageView? (0) | 2020.10.09 |
---|---|
Xcode 5-DVTPlugInCompatibilityUUID에 필요한 플러그인이 없습니까? (0) | 2020.10.09 |
iPhone WebKit CSS 애니메이션으로 인해 깜박임 발생 (0) | 2020.10.09 |
텍스트 영역 스크롤 막대를 기본값으로 아래쪽으로 설정하려면 어떻게합니까? (0) | 2020.10.09 |
격리 범위가있는 지시문의 템플릿에서 $ rootScope에 액세스 할 수없는 이유는 무엇입니까? (0) | 2020.10.09 |