리눅스 CentOS - Git 설치 및 Bitbucket 설정

2017. 8. 16. 00:16





[ Git 설치 ]




CentOs 리눅스에 Git 설치


# yum -y update
# yum -y install git


Git 설치 끝






[ Git 으로 원격저장소 저장하기 ]


설치된 git명령으로 Bitbucket에 있는 저장소 내용을 로컬에 저장해 보자

SSH주소를 통해 clone 한다



bitbucket SSH주소 얻기

Bitbucket 의 SSH 주소를 복사한다.


[팁] http URL로 연동해도되는데 계정과 비밀번호가 노출되니 SSH로 연동하는것을 추천


git clone 명령 실행

# git clone [bitbucket SSH주소]


SSH로 처음접속하는것으로 접속여부를 묻는다. yes 를 입력한다.


이후 에러가 표시되고 저장소 저장이 안된다. 내용은 아래와 같다


-----

[root@cobot git]# git clone git@bitbucket.org:***/*****.git

Cloning into 'cobot'...

The authenticity of host 'bitbucket.org (111.111.111.111)' can't be established.

RSA key fingerprint is *********************************************.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'bitbucket.org,111.111.111.111' (RSA) to the list of known hosts.

Connection closed by ???.???.???.???

fatal: Could not read from remote repository.


Please make sure you have the correct access rights

and the repository exists.

---


Clone가 안된다.... 이유는 bitbucket에 SSH키 등록이 안되어서다






SSH Key 생성

# ssh-keygen -t rsa

linux나 macos에서 ssh-keygen 명령으로 ssh키를 생성할 수 있다.



엔터만 입력했다면 이후 생성된 id_rsa.pub 파일 내용을 복사한다.

# cat /root/.ssh/id_rsa.pub






Bitbucket SSH Key 등록

Settings > Add Key 버튼을 클릭



id_rsa.pub 내용을 붙여넣기 한다.





Git Clone 한다.




Bitbucket의 원격 저장소를 로컬 저장소로 저장이 완료되었다