티스토리 뷰

ssh git 연결방법


아래와 같이 ssh로 git clone 시도시 암호를 입력하라고 나온다.
[user@server project]$ git clone git@git주소:레파지토리.git 
Cloning into '레파지토리'...
The authenticity of host 'git주소 (10.1.1.1)' can't be established.
RSA key fingerprint is ed:c0:13:07:~~~.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git주소 (10.1.1.1)' (RSA) to the list of known hosts.
git@git주소's password:
Permission denied, please try again.
git@pubgit.four33.co.kr's password:
ssh 연결을 위하여 키를 생성한다

[user@server project]$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/user/.ssh/id_rsa): Enter passphrase (empty for no passphrase):암호안만들면엔터 Enter same passphrase again:암호안만들면엔터 Your identification has been saved in /home/user/.ssh/id_rsa. Your public key has been saved in /home/user/.ssh/id_rsa.pub. The key fingerprint is: 5f:e7:6b:8f:af:96:33:7e:ea~~~f7:a0 user@server The key's randomart image is: +--[ RSA 2048]----+ | | | | | | | | | S . . | | . . o. o| | . ..+=| | 999B=B| | =O&B| +-----------------+

아래와 같이 공개키(~.pub) 와 개인키가 생성된것을 확인할 수 있다.
[user@server .ssh]$ ll
total 20
drwx------ 2 user platform 4096 Nov 28 16:02 .
drwx------ 4 user platform 4096 Nov 28 15:53 ..
-rw------- 1 user platform 1675 Nov 28 16:02 id_rsa
-rw-r--r-- 1 user platform  399 Nov 28 16:02 id_rsa.pub
-rw-r--r-- 1 user platform  416 Nov 28 15:54 known_hosts
공개키를 확인하여 복사한담에 git의 ssh 연결설정정보에 넣어주면 끝. 
[user@server.ssh]$ cat id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAv3H8yOFocJTAOLhrjhN9N6UTC9OlRCNCiMcQ4+LBhVYeH2YcpsyOLsbW18JmCnsKiovdw4CFl7QbCjqYKa90cARa7mhCmmzoj0+zjFO6jkwUcyEkpmifr5IV6VRSPui7WKaVYxWXI2TOHZAFly1xA9JeMEvRZUdK54nAHbp/JK/KiNTyjdKNPNYAgPpmLEVQPxMJLxKH86H



ssh Eclipse에서  연결 방법

Window -> Preferences -> 왼쪽상단 ssh 검색



두번째탭 Key Management -> Generate RSA Key



그림과 같이 생성된 Public키를 확인 할 수 있다. 

암호를 추가하려면 Passphrase를 추가하면 된다. (암호없이 그냥 키만 인증되면 접속할 수 있도록 나는 빈칸으로)

키가 생성되면 Save Private Key.. 버튼으로 로컬에 private key를 저장한다. 

그리고 public키는 복사하여 내가 가지고 있는 git사이트의 계정정보에 ssh에 추가한다.


이 절차가 끝나고 나면 내 이클립스에서는 ssh git 연결시 해당RSA키로 자동 인증되기 때문에 매번 패스워드를 입력할 필요가 없다. 


'개발관련' 카테고리의 다른 글

Springboot response server-header 숨기기  (4) 2017.09.25
Jenkins Remote API  (0) 2017.03.27
Jenkins Window 설치  (0) 2017.03.07
oAuth와 SSO의 차이  (0) 2017.02.01
원격접속 프로그램  (0) 2017.01.27
댓글