Share
Sign In
👥

git SSH 특정 레포지토리만 다른 Github 계정 쓰기 (Use Multiple Account and SSH keys)

A 계정으로 git 을 이미 사용하고 있는 중, B 계정으로 B 계정의 레포지토리에 push를 해야하는 경우 어떻게 하는 지 알아본다.
SSH key 생성하기
홈 디렉토리의.ssh 폴더로 이동 (없으면 생성한다.)
mkdir .ssh # 없을 시 cd ~/.ssh
키젠 사용
ssh-keygen -t rsa -b 4096 -C "example@email.com" -f my-ssh-keys.pem
-t rsa : 암호화 방법을 rsa로 한다.
-b 4096 : 생성할 bit 수를 4096 bit 으로 지정. rsa는 최소 768 비트가 필요, default는 2048 bit 이다.
-C “example@email.com” : 이메일 주석 삽입
-f : 파일명을 설정한다.
Multiple GitHub Accounts and SSH Keys 사용하기
~/.ssh 의 하위 폴더에 config 파일이 있는지 확인
vim ~/.ssh/config
~/.ssh/config 작성
# Default Config - Work profile Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa # Secondary Config - Personal profile Host github.com-office HostName github.com User git IdentityFile ~/.ssh/id_rsa_office
ssh를 사용하여 repo 연결
# Using default work profile git@github.com:ho4607/my-first-project.git # Using Secondary work profile git@github.com-office:seongho-park-office/private-office-project.git
현재 사용하고 있는 name, email 확인하기
global 기준 git name과 eamil 조회
git config --global user.name #output : global username git config --global user.email #output : global userEmail
현재 레포지토리 기준으로 git name 과 email 조회
git config user.name #output : username git config user.email #output : userEmail
현재 리포지토리만 다른 Github 계정 쓰기
로컬 name, email 변경
git config --local user.name "유저이름" git config --local user.email "유저이메일"
이를 설정하면 깃 커밋메세지에 설정된 유저이름과 이메일로 기록된다.
global name, email 변경
설정 후 바로 push 하려고 하면 다음과 같은 형식의 에러가 뜬다.
remote: Permission to @@@@@/@@@@@@.git denied to <기존사용계정>. fatal: unable to access '깃주소': The requested URL returned error: 403
그때 아래와 같이 명령어 몇 줄을 입력해준다.
git config --local credential.useHttpPath true git remote set-url origin https://USERNAME@github.com/USERNAME/REPONAME.git
push를 해보면 Github 로그인 창이 뜨고, 로그인하면 이후 해당 Repository 에서만 지정한 계정으로 push 된다.
깃 ssh Key 사용하기
A 계정으로 git 을 이미 사용하고 있는 중, B 계정으로 B 계정의 레포지토리에 push를 해야하는 경우 어떻게 하는 지 알아본다.
SSH key 생성하기
홈 디렉토리의.ssh 폴더로 이동 (없으면 생성한다.)
mkdir .ssh # 없을 시 cd ~/.ssh
키젠 사용
ssh-keygen -t rsa -b 4096 -C "example@email.com" -f my-ssh-keys.pem
-t rsa : 암호화 방법을 rsa로 한다.
-b 4096 : 생성할 bit 수를 4096 bit 으로 지정. rsa는 최소 768 비트가 필요, default는 2048 bit 이다.
-C “example@email.com” : 이메일 주석 삽입
-f : 파일명을 설정한다.
Multiple GitHub Accounts and SSH Keys 사용하기
~/.ssh 의 하위 폴더에 config 파일이 있는지 확인
vim ~/.ssh/config
~/.ssh/config 작성
# Default Config - Work profile Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa # Secondary Config - Personal profile Host github.com-office HostName github.com User git IdentityFile ~/.ssh/id_rsa_office
ssh를 사용하여 repo 연결
# Using default work profile git@github.com:ho4607/my-first-project.git # Using Secondary work profile git@github.com-office:seongho-park-office/private-office-project.git
현재 사용하고 있는 name, email 확인하기
global 기준 git name과 eamil 조회
git config --global user.name #output : global username git config --global user.email #output : global userEmail
현재 레포지토리 기준으로 git name 과 email 조회
git config user.name #output : username git config user.email #output : userEmail
현재 리포지토리만 다른 Github 계정 쓰기
로컬 name, email 변경
git config --local user.name "유저이름" git config --local user.email "유저이메일"
이를 설정하면 깃 커밋메세지에 설정된 유저이름과 이메일로 기록된다.
global name, email 변경
설정 후 바로 push 하려고 하면 다음과 같은 형식의 에러가 뜬다.
remote: Permission to @@@@@/@@@@@@.git denied to <기존사용계정>. fatal: unable to access '깃주소': The requested URL returned error: 403
그때 아래와 같이 명령어 몇 줄을 입력해준다.
git config --local credential.useHttpPath true git remote set-url origin https://USERNAME@github.com/USERNAME/REPONAME.git
push를 해보면 Github 로그인 창이 뜨고, 로그인하면 이후 해당 Repository 에서만 지정한 계정으로 push 된다.
깃 ssh Key 사용하기
A 계정으로 git 을 이미 사용하고 있는 중, B 계정으로 B 계정의 레포지토리에 push를 해야하는 경우 어떻게 하는 지 알아본다.
SSH key 생성하기
홈 디렉토리의.ssh 폴더로 이동 (없으면 생성한다.)
mkdir .ssh # 없을 시 cd ~/.ssh
키젠 사용
ssh-keygen -t rsa -b 4096 -C "example@email.com" -f my-ssh-keys.pem
-t rsa : 암호화 방법을 rsa로 한다.
-b 4096 : 생성할 bit 수를 4096 bit 으로 지정. rsa는 최소 768 비트가 필요, default는 2048 bit 이다.
-C “example@email.com” : 이메일 주석 삽입
-f : 파일명을 설정한다.
Multiple GitHub Accounts and SSH Keys 사용하기
~/.ssh 의 하위 폴더에 config 파일이 있는지 확인
vim ~/.ssh/config
~/.ssh/config 작성
# Default Config - Work profile Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa # Secondary Config - Personal profile Host github.com-office HostName github.com User git IdentityFile ~/.ssh/id_rsa_office
ssh를 사용하여 repo 연결
# Using default work profile git@github.com:ho4607/my-first-project.git # Using Secondary work profile git@github.com-office:seongho-park-office/private-office-project.git
현재 사용하고 있는 name, email 확인하기
global 기준 git name과 eamil 조회
git config --global user.name #output : global username git config --global user.email #output : global userEmail
현재 레포지토리 기준으로 git name 과 email 조회
git config user.name #output : username git config user.email #output : userEmail
현재 리포지토리만 다른 Github 계정 쓰기
로컬 name, email 변경
git config --local user.name "유저이름" git config --local user.email "유저이메일"
이를 설정하면 깃 커밋메세지에 설정된 유저이름과 이메일로 기록된다.
global name, email 변경
설정 후 바로 push 하려고 하면 다음과 같은 형식의 에러가 뜬다.
remote: Permission to @@@@@/@@@@@@.git denied to <기존사용계정>. fatal: unable to access '깃주소': The requested URL returned error: 403
그때 아래와 같이 명령어 몇 줄을 입력해준다.
git config --local credential.useHttpPath true git remote set-url origin https://USERNAME@github.com/USERNAME/REPONAME.git
push를 해보면 Github 로그인 창이 뜨고, 로그인하면 이후 해당 Repository 에서만 지정한 계정으로 push 된다.
깃 ssh Key 사용하기
A 계정으로 git 을 이미 사용하고 있는 중, B 계정으로 B 계정의 레포지토리에 push를 해야하는 경우 어떻게 하는 지 알아본다.
SSH key 생성하기
홈 디렉토리의.ssh 폴더로 이동 (없으면 생성한다.)
mkdir .ssh # 없을 시 cd ~/.ssh
키젠 사용
ssh-keygen -t rsa -b 4096 -C "example@email.com" -f my-ssh-keys.pem
-t rsa : 암호화 방법을 rsa로 한다.
-b 4096 : 생성할 bit 수를 4096 bit 으로 지정. rsa는 최소 768 비트가 필요, default는 2048 bit 이다.
-C “example@email.com” : 이메일 주석 삽입
-f : 파일명을 설정한다.
Multiple GitHub Accounts and SSH Keys 사용하기
~/.ssh 의 하위 폴더에 config 파일이 있는지 확인
vim ~/.ssh/config
~/.ssh/config 작성
# Default Config - Work profile Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa # Secondary Config - Personal profile Host github.com-office HostName github.com User git IdentityFile ~/.ssh/id_rsa_office
ssh를 사용하여 repo 연결
# Using default work profile git@github.com:ho4607/my-first-project.git # Using Secondary work profile git@github.com-office:seongho-park-office/private-office-project.git
현재 사용하고 있는 name, email 확인하기
global 기준 git name과 eamil 조회
git config --global user.name #output : global username git config --global user.email #output : global userEmail
현재 레포지토리 기준으로 git name 과 email 조회
git config user.name #output : username git config user.email #output : userEmail
현재 리포지토리만 다른 Github 계정 쓰기
로컬 name, email 변경
git config --local user.name "유저이름" git config --local user.email "유저이메일"
이를 설정하면 깃 커밋메세지에 설정된 유저이름과 이메일로 기록된다.
global name, email 변경
설정 후 바로 push 하려고 하면 다음과 같은 형식의 에러가 뜬다.
remote: Permission to @@@@@/@@@@@@.git denied to <기존사용계정>. fatal: unable to access '깃주소': The requested URL returned error: 403
그때 아래와 같이 명령어 몇 줄을 입력해준다.
git config --local credential.useHttpPath true git remote set-url origin https://USERNAME@github.com/USERNAME/REPONAME.git
push를 해보면 Github 로그인 창이 뜨고, 로그인하면 이후 해당 Repository 에서만 지정한 계정으로 push 된다.
깃 ssh Key 사용하기
A 계정으로 git 을 이미 사용하고 있는 중, B 계정으로 B 계정의 레포지토리에 push를 해야하는 경우 어떻게 하는 지 알아본다.
SSH key 생성하기
홈 디렉토리의.ssh 폴더로 이동 (없으면 생성한다.)
mkdir .ssh # 없을 시 cd ~/.ssh
키젠 사용
ssh-keygen -t rsa -b 4096 -C "example@email.com" -f my-ssh-keys.pem
-t rsa : 암호화 방법을 rsa로 한다.
-b 4096 : 생성할 bit 수를 4096 bit 으로 지정. rsa는 최소 768 비트가 필요, default는 2048 bit 이다.
-C “example@email.com” : 이메일 주석 삽입
-f : 파일명을 설정한다.
Multiple GitHub Accounts and SSH Keys 사용하기
~/.ssh 의 하위 폴더에 config 파일이 있는지 확인
vim ~/.ssh/config
~/.ssh/config 작성
# Default Config - Work profile Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa # Secondary Config - Personal profile Host github.com-office HostName github.com User git IdentityFile ~/.ssh/id_rsa_office
ssh를 사용하여 repo 연결
# Using default work profile git@github.com:ho4607/my-first-project.git # Using Secondary work profile git@github.com-office:seongho-park-office/private-office-project.git
현재 사용하고 있는 name, email 확인하기
global 기준 git name과 eamil 조회
git config --global user.name #output : global username git config --global user.email #output : global userEmail
현재 레포지토리 기준으로 git name 과 email 조회
git config user.name #output : username git config user.email #output : userEmail
현재 리포지토리만 다른 Github 계정 쓰기
로컬 name, email 변경
git config --local user.name "유저이름" git config --local user.email "유저이메일"
이를 설정하면 깃 커밋메세지에 설정된 유저이름과 이메일로 기록된다.
global name, email 변경
설정 후 바로 push 하려고 하면 다음과 같은 형식의 에러가 뜬다.
remote: Permission to @@@@@/@@@@@@.git denied to <기존사용계정>. fatal: unable to access '깃주소': The requested URL returned error: 403
그때 아래와 같이 명령어 몇 줄을 입력해준다.
git config --local credential.useHttpPath true git remote set-url origin https://USERNAME@github.com/USERNAME/REPONAME.git
push를 해보면 Github 로그인 창이 뜨고, 로그인하면 이후 해당 Repository 에서만 지정한 계정으로 push 된다.
깃 ssh Key 사용하기
A 계정으로 git 을 이미 사용하고 있는 중, B 계정으로 B 계정의 레포지토리에 push를 해야하는 경우 어떻게 하는 지 알아본다.
SSH key 생성하기
홈 디렉토리의.ssh 폴더로 이동 (없으면 생성한다.)
mkdir .ssh # 없을 시 cd ~/.ssh
키젠 사용
ssh-keygen -t rsa -b 4096 -C "example@email.com" -f my-ssh-keys.pem
-t rsa : 암호화 방법을 rsa로 한다.
-b 4096 : 생성할 bit 수를 4096 bit 으로 지정. rsa는 최소 768 비트가 필요, default는 2048 bit 이다.
-C “example@email.com” : 이메일 주석 삽입
-f : 파일명을 설정한다.
Multiple GitHub Accounts and SSH Keys 사용하기
~/.ssh 의 하위 폴더에 config 파일이 있는지 확인
vim ~/.ssh/config
~/.ssh/config 작성
# Default Config - Work profile Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa # Secondary Config - Personal profile Host github.com-office HostName github.com User git IdentityFile ~/.ssh/id_rsa_office
ssh를 사용하여 repo 연결
# Using default work profile git@github.com:ho4607/my-first-project.git # Using Secondary work profile git@github.com-office:seongho-park-office/private-office-project.git
현재 사용하고 있는 name, email 확인하기
global 기준 git name과 eamil 조회
git config --global user.name #output : global username git config --global user.email #output : global userEmail
현재 레포지토리 기준으로 git name 과 email 조회
git config user.name #output : username git config user.email #output : userEmail
현재 리포지토리만 다른 Github 계정 쓰기
로컬 name, email 변경
git config --local user.name "유저이름" git config --local user.email "유저이메일"
이를 설정하면 깃 커밋메세지에 설정된 유저이름과 이메일로 기록된다.
global name, email 변경
설정 후 바로 push 하려고 하면 다음과 같은 형식의 에러가 뜬다.
remote: Permission to @@@@@/@@@@@@.git denied to <기존사용계정>. fatal: unable to access '깃주소': The requested URL returned error: 403
그때 아래와 같이 명령어 몇 줄을 입력해준다.
git config --local credential.useHttpPath true git remote set-url origin https://USERNAME@github.com/USERNAME/REPONAME.git
push를 해보면 Github 로그인 창이 뜨고, 로그인하면 이후 해당 Repository 에서만 지정한 계정으로 push 된다.
깃 ssh Key 사용하기
A 계정으로 git 을 이미 사용하고 있는 중, B 계정으로 B 계정의 레포지토리에 push를 해야하는 경우 어떻게 하는 지 알아본다.
SSH key 생성하기
홈 디렉토리의.ssh 폴더로 이동 (없으면 생성한다.)
mkdir .ssh # 없을 시 cd ~/.ssh
키젠 사용
ssh-keygen -t rsa -b 4096 -C "example@email.com" -f my-ssh-keys.pem
-t rsa : 암호화 방법을 rsa로 한다.
-b 4096 : 생성할 bit 수를 4096 bit 으로 지정. rsa는 최소 768 비트가 필요, default는 2048 bit 이다.
-C “example@email.com” : 이메일 주석 삽입
-f : 파일명을 설정한다.
Multiple GitHub Accounts and SSH Keys 사용하기
~/.ssh 의 하위 폴더에 config 파일이 있는지 확인
vim ~/.ssh/config
~/.ssh/config 작성
# Default Config - Work profile Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa # Secondary Config - Personal profile Host github.com-office HostName github.com User git IdentityFile ~/.ssh/id_rsa_office
ssh를 사용하여 repo 연결
# Using default work profile git@github.com:ho4607/my-first-project.git # Using Secondary work profile git@github.com-office:seongho-park-office/private-office-project.git
현재 사용하고 있는 name, email 확인하기
global 기준 git name과 eamil 조회
git config --global user.name #output : global username git config --global user.email #output : global userEmail
현재 레포지토리 기준으로 git name 과 email 조회
git config user.name #output : username git config user.email #output : userEmail
현재 리포지토리만 다른 Github 계정 쓰기
로컬 name, email 변경
git config --local user.name "유저이름" git config --local user.email "유저이메일"
이를 설정하면 깃 커밋메세지에 설정된 유저이름과 이메일로 기록된다.
global name, email 변경
설정 후 바로 push 하려고 하면 다음과 같은 형식의 에러가 뜬다.
remote: Permission to @@@@@/@@@@@@.git denied to <기존사용계정>. fatal: unable to access '깃주소': The requested URL returned error: 403