개인 랩탑에서 Bitbucket Repository를 SSH로 클론해 사용할 때 생겼던 문제들을 해결한 과정을 기록해본다.
1. Bitbucket 연결 안됨
ssh: connect to host bitbucket.org.port 22: Connection timed out
git clone git@bitbucket.org:[repository].git 를 이용해 클론할 때, 한참 동안 clone 시작 문구만 떠있다가 위와 같은 에러가 떴다.
아틀라시안 커뮤니티에는 방화벽 문제라고 답변이 달렸고, 이 글을 바탕으로 아래 커맨드로 방화벽 테스트를 하여 해결할 수 있었다.
nc -z -v bitbucket.org 22
2. SSH 키 등록
Git error: "Please make sure you have the correct access rights and the repository exists"
그 다음으로는 레포지토리에 대한 권한이 없다는 깃 에러가 발생했다.
해결하기 위해선 SSH 키를 생성하고 내 빗버킷 계정에 등록해주어야한다.
ssh 디렉토리에서 키를 확인할 수 있는데, .pub이 붙은 것이 공개키이다. 물론 처음엔 known_hosts 밖에 없었다!
$ cd ~/.ssh
$ ls
id_rsa id_rsa.pub known_hosts
ssh-keygen을 이용해 ssh 키를 생성해준다.
passphrase 입력하라는 단계에서는 값없이 엔터로 넘어가주면 키를 사용할 때 암호없이 사용할 수 있다.
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/diana/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/diana/.ssh/id_rsa.
Your public key has been saved in /Users/diana/.ssh/id_rsa.pub.
The key fingerprint is:
생성된 공개키는 cat id_rsa.pub 하여 확인할 수 있다.
이제 Bitbucket - Personal settings - Security - SSH keys에 등록해주면 레포지토리를 정상적으로 클론할 수 있다 😎
