Development/Git

[Git] SSH Key로 접속하기

jstar0525 2022. 7. 25. 14:48
반응형

1. Checking for existing SSH keys

$ ls -al ~/.ssh
id_rsa.pub
id_ecdsa.pub
id_ed25519.pub

# 없을 경우 
# 2. Generating a new SSH key and adding it to the ssh-agent 
# 3. Adding a new SSH key to your GitHub account

# 있을 경우 
# 3. Adding a new SSH key to your GitHub account

 

2. Generating a new SSH key and adding it to the ssh-agent

1) Generating a new SSH key

$ ssh-keygen -t ed25519 -C "your_email@example.com"
# Enter 3번 누르기

2) Adding your SSH key to the ssh-agent

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

 

3. Adding a new SSH key to your GitHub account

1) About addition of SSH keys to your account

$ cat ~/.ssh/id_ed25519.pub
# 이후 나오는 정보 copy

2) Gihub 아래 설정으로 이동

3) SSH 정보 입력

- 다른 SSH와 구별할 수 있는 Title 입력

- 아까 $ cat ~/.ssh/id_ed25519.pub 명령으로 나온 정보를 Key에 붙여넣기

- Add SSH Key

 

4. Git clone

- 해당 리포지터리에 이동하여 ssh copy

- 저장하고 싶은 디렉토리로 이동하여 아래 명령 수행

$ git clone git@github.com:jstar0525/MachineVision.git

 

5. Commit하기 위해 config 설정

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

 

ref.

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/checking-for-existing-ssh-keys

 

Checking for existing SSH keys - GitHub Docs

Note: GitHub improved security by dropping older, insecure key types on March 15, 2022. As of that date, DSA keys (ssh-dss) are no longer supported. You cannot add new DSA keys to your personal account on GitHub.com. RSA keys (ssh-rsa) with a valid_after b

docs.github.com

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

 

Generating a new SSH key and adding it to the ssh-agent - GitHub Docs

About SSH key generation If you don't already have an SSH key, you must generate a new SSH key to use for authentication. If you're unsure whether you already have an SSH key, you can check for existing keys. For more information, see "Checking for existin

docs.github.com

 

Adding a new SSH key to your GitHub account - GitHub Docs

Before adding a new SSH key to your account on GitHub.com, you should have: After adding a new SSH key to your account on GitHub.com, you can reconfigure any local repositories to use SSH. For more information, see "Switching remote URLs from HTTPS to SSH.

docs.github.com

 

반응형