git:: multi account ssh set for github, howto 2개 계정으로 깃허브 접속 방법

 

2개 계정을 사용하여 접속하기 위한 SSH 설정

# FOR WINDOWS
# By default the ssh-agent service is disabled. Configure it to start automatically.
# Make sure you're running as an Administrator.
Get-Service ssh-agent | Set-Service -StartupType Automatic
 
# Start the service
Start-Service ssh-agent
 
# This should return a status of Running
Get-Service ssh-agent
 
# Now load your key files into ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519
 
__________________________________
 
 
# key generation
ssh-keygen -t ed25519 -C "myaccount@gmail.com"
ssh-keygen -t ed25519 -C "additional@gmail.com"
 
 
# key copy for public
  at Windows
cat ~/.ssh/id_ed25519_my.pub | clip
 
  at Mac
cat id_ed25519_my.pub | pbcopy
pbcoby < id_ed25519_my.pub
 
 
 
 
# check ssh status and Add
eval "$(ssh-agent -s)" && ssh-add -K id_ed25519_my 
 
ssh-add ~/.ssh/id_ed25519_my
ssh-add ~/.ssh/id_ed25519_additional
 
# check ADD result
ssh-add -l
 
# for Test connection
ssh -T git@github.com
ssh -T git@additional
 
# check Write permission, show #600
cd ~
ls -l 
 
 
 
---------------------
~/.ssh 
touch config
 
 
# Default
Host github.com
 HostName github.com
 User git
 PreferredAuthentications publickey,keyboard-interactive,password
 IdentitiesOnly yes
 IdentityFile ~/.ssh/id_ed25519_my
 
# Additional
Host additional
 HostName github.com
 User git
 PreferredAuthentications publickey,keyboard-interactive,password
 IdentitiesOnly yes
 IdentityFile ~/.ssh/id_ed25519_additional



git clone 할 때

git clone {HOST-NAME}:{GIT-URL}
 
git clone git@github.com:myID/blog-hexo-12.git
git clone additional:myID/blog-hexo-12.git


# .gitconfig 설정
 
[user]
    name = b660
    email = private@email.com
[includeIf "gitdir:D:/repo/myRepo1/"]
        	path = .gitconfig-work
[includeIf "gitdir:~/repo/myRepo2/"]
    		path = .gitconfig-work
[push]
    default = current
[core]
    autocrlf = input
    
    
# .gitconfig-work 설정
[user]
    name = work Account
    email = work@email.com


# windows Enable "ssh-add" service
Set-Service   ssh-agent -StartupType Automatic
Start-Service ssh-agent
 
 
 
# If ssh-add NOT available
Get-Service ssh-agent
Get-Service ssh-agent | Select StartType
 
ssh-agent.exe






# 현재 폴더의 git config 설정조회
git config --list --local
 
git config --local user.email "the@gmail.com"
git config --local user.name "the"




댓글 쓰기 · 수정

0 댓글