본문 바로가기
Programming/Git

SSH key & multi GitHub & IntelliJ

by Chan_찬 2016. 3. 25.
728x90

SSH key 발급

  1. git bash에서 실행 

  2. 아래 명령 입력, 이메일은 수정
     $ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"  

  3. 엔터 클릭
     Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]  

  4. SSH 암호 입력, 암호입력없이 하려면 엔터
    Enter passphrase (empty for no passphrase): [Type a passphrase]
    Enter same passphrase again: [Type passphrase again]

  5. ssh key 클립보드에 복사
    $ clip < ~/.ssh/id_rsa.pub


발급한 SSH key를 ssh-agent에 등록

  1. ssh-agent 시작하기 

    # start the ssh-agent in the background
    Git Bash
    $ eval "$(ssh-agent -s)"
    다른 terminal
    $ eval $(ssh-agent -s)

  2. SSH key를 ssh-agent에 추가
    $ ssh-add ~/.ssh/id_rsa

GitHub 계정에 SSH key 등록

  1. Sign in > 아이콘 클릭 > Settings

  2. SSH keys > New SSH key 

  3. Title 입력, Key > Ctrl+V 

  4. Addd SSH key 

     

  5. GitHub 암호 입력

     


Multi SSH keys 셋팅

  1. 위의 방법으로 여러개의 키를 생성, ssh-agent에 추가

  2. 저장된 keys 확인
    $ ssh-add -l

  3. ssh config 수정

    $ cd ~/.ssh/
    $ touch config
    $ vi config
  4. 내용추가

    #activehacker GitHub계정ID
    Host github.com-activehacker
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_rsa_activehacker
    
    #jexchan GitHub계정ID
    Host github.com-jexchan
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_rsa_jexchan

IntelliJ 에 SSH key 적용

  1. VCS > Checkout from Version Control > Git

    github.com-jexchan: config에서 설정한 Host
    jexchan: github의 id
    repo: repository 이름

    Git Repository URL: github.com-jexchan:jexchan/repo
    Parent Directory: /User/workspace
    Directory Name: repo

  2. Test 클릭

  3. Clone 클릭


728x90
728x90

'Programming > Git' 카테고리의 다른 글

git pull overwrite  (0) 2020.06.10
git pull without login - for gitlab  (0) 2020.06.09
git diff patch - 패치 생성/적용  (0) 2020.06.08
git add 취소  (0) 2020.06.08
git push하기 - terminal  (0) 2016.04.01
Buy me a coffeeBuy me a coffee

댓글