1. SSH Key 생성

SSH Key가 필요한 이유? ➡️ 보안성, 편의성

  • 보안 강화: SSH 키는 안전한 암호화 기반 인증 방법을 제공하여 계정의 보안을 강화한다.
  • 편의성: github 계정을 여러 개 편하게 관리할 수 있으며, SSH 키를 사용하면 매번 GitHub에 로그인할 때마다 사용자 이름과 암호를 입력하는 번거로움을 피할 수 있다

1) 폴더 이동 및 리스트 확인

cd ~/.ssh
ls

2) SSH Key 생성 및 확인

ssh-keygen -t rsa -C "narae3759@github.com" -f "id_rsa_github"
  • -t : 인증 종류
  • -C : Comment
  • -f : key 파일 이름

폴더에 id_rsa_github(개인키), id_rsa_github.pub(공개키) 생성되었는지 확인

ls

삭제하고 싶을 때에는 다음과 같이 입력한다.

rm ~/.ssh/id_rsa_github
rm ~/.ssh/id_rsa_github.pub

3) ssh-agent에 저장

따로 저장하지 않아도 상관없지만, ssh key에 비밀번호를 한번만 입력하면 다음에 기억해서 다시 입력할 필요가 없어서 편리하다.

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa_github

잘 추가되었는지 확인

ssh-add -l

2. SHH Key 등록

1) 내용 복사

cat id_rsa_github.pub

2) 붙여넣기

[Settings] - [SSH and GPG Keys] - [New SSH key] - 📄붙여넣기 - [Add SSH key]

3. SSH Config 설정

1) vscode에서 config 파일 열기

[F1] > [Remote-SSH: Connect to Host…] > [Configure SSH Hosts…] > [C:\Users\user\.ssh\config]

2) 계정에 대한 SSH 설정

Host github.com-narae3759
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_github

3) 확인

  • 🚨 bash가 아닌 cmd에서 확인
ssh -T git@github.com-narae3759
>>> Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
>>> Hi narae3759! You've successfully authenticated, but GitHub does not provide shell access.

4. Repository Clone

1) Repository SSH 복사

git@github.com:narae3759/PPS.git

2) SSH 변경 후 Clone

git clone git@github.com-narae3759:narae3759/PPS.git

Reference

태그: ,

카테고리:

업데이트:

댓글남기기