티스토리 뷰

Problem

ssh key-gen -> gitlab에서 ssh 등록 했음에도 안되어서 https + token 으로 하던 중,,

repo init, sync 시에 ssh 로 되어있어서 ssh 되는 방법 서칭..

(manifest.xml 수정해서 https 로 변경할 수 있지만 너무 방대했음 ㅜㅜ)

 

$ git fetch origin
git@gitlab.com: Permission denied (publickey).
fatal: 리모트 저장소에서 읽을 수 없습니다

올바른 접근 권한이 있는지, 그리고 저장소가 있는지
확인하십시오.

ssh-key 삭제, gitlab 재등록 몇번을 해도 안되었는데,,

구글링 중 아래와 같이 해결책 발견 ㅜㅜ

https://gist.github.com/alejandro-martin/aabe88cf15871121e076f66b65306610#creating-config-file-for-manage-ssh-keys

 

Configure multiple SSH Keys for Git

Configure multiple SSH Keys for Git. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

 

Solution

~/.ssh/config 파일 생성 후 ssh server 에 대한 키값 정보 등록

# gitlab account
Host gitlab.com
HostName gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa

gitlab 만 사용할거라서 위 내용만 추가했지만 github 같이 다른 host 로 ssh 접근이 필요한 경우 아래처럼 config 파일에 append 하면 되는 것 같음..

# github account
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_myaccount_github

'IT > Linux' 카테고리의 다른 글

리눅스 서버 테스트할 수 있는 사이트  (0) 2023.10.20
cmake  (1) 2023.01.06
__VA_ARGS__  (0) 2022.09.23
구조체 패딩비트 todo  (0) 2022.09.08
Local <-> K8s pod 간 파일 복사  (0) 2022.03.19