전체/장난하기
Ssh access git repository
Coolen
2021. 2. 2. 09:57
git repository 서비스를 제공하는 bitbucket, github, gitlab 등은 ssh key를 등록하여 사용한다. 내 ssh-keygen으로 생성한 비밀키/공개키 쌍 중에서 공개키에 해당하는 ~/.ssh/id_rsa.pub 파일의 내용을 복사해서 등록하는 방식이다.
그리고 ssh 로 해당서비스를 접근할 때, 사용자 이름을 git 으로 하면, 서비스에 가입한 ID를 화면에 출력하고 바로 접속을 끊는다. 아래 예에서는 "exampleuser" 로 가입했을 때 나오는 모습이다.
$ ssh git@bitbucket.org
PTY allocation request failed on channel 0
logged in as exampleuser
You can use git or hg to connect to Bitbucket. Shell access is disabled
Connection to bitbucket.org closed.
$ ssh git@github.com
PTY allocation request failed on channel 0
Hi exampleuser! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
$ ssh git@gitlab.com
PTY allocation request failed on channel 0
Welcome to GitLab, @exampleuser!
Connection to gitlab.com closed.
또는 사용자 지정을 -l 옵션을 사용하고, 터미널이 굳이 필요없으므로 -T를 주어 터미널 없이 접근한다면, 다음과 같다.
$ ssh github.com -l git -T
Hi exampleuser! You've successfully authenticated, but GitHub does not provide shell access.
SSH의 공개키를 접근할 서버에 등록하여 인증하는 방법은 비밀번호 입력없이 로그인 하는 방법으로 많이 사용되며, 이 서비스들은 ssh 프로토콜에서 모두 같은 ID(git)로 접속하되, 공개키를 다르게 하여 실제 사용자를 구별한다.
그냥 이 서비스들이 이렇게 구현되어 있다.
반응형